Giter VIP home page Giter VIP logo

swr-sync-storage's Issues

Request feature: Choose what key save in localstorage

Hi, if I use load more scroll, that will be much data in localstorage.
I hope you can edit more to archive which key should we cache

I want something like this
import { syncWithStorage } from "swr-sync-storage";
syncWithStorage("local",["key-i-want-to-save"]); // this key just in localstorage, not in session too. And regex will be more great i think
syncWithStorage("session",["key-i-want-to-save"]);

cause the swr's key serialization, it it should do not work with key of Array type

key serialization: https://github.com/vercel/swr/blob/master/src/cache.ts#L45
think of the using as follow

function App() {
  const {data} = useSWR('/api/a');
  const {data} = useSWR(['/api/list', {id: data.id}], fetcher);
}

the key may serialize to /api/list0,
{name: 'xxx', age: 'xxx'} will transform to a Incremental number

page1

function App() {
  const {data} = useSWR(['/api/list', {id: '1'}], fetcher);
}

page2

function App() {
  const {data} = useSWR(['/api/list', {id: '2'}], fetcher);
}

when i open page1 and page2, ['/api/list', {id: '1'}] and ['/api/list', {id: '2'}] will be serialized to /api/list0, but they stand for a different query. so they may use the error data

Help with alternatives

Hi. I keep stumbling across this repo and your comments on other peoples issues.
It seems this packages is not maintained anymore - could you recommend any alternatives?

I have already tried react query, but prefer SWR, but maybe you know of others?

Kind regards
Dennis

Example

Hi can you make a simple example for use this? I am trying to save public user info to local.
I use localStorage with SWR but it not work well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.