0.9.0 • Published 3 years ago

react-localstorage-layer v0.9.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

React LocalStorage Layer

This package makes localStorage state available to your app. It maintains a shared context that syncs localStorage state updates

  1. Wrap your app with LocalStorageContextProvider:
function () {
    return (
        <LocalStorageContextProvider>
            <App />
        </LocalStorageContextProvider>
    )
}
  1. Use useLocalStorageState to get or set localStorage state
function Example() {
    const [n, setN] = useLocalStorageState('n', 0);

    return (
        <div>
            <button onClick={() => setN(n+1)}>{n}</button>
        </div>
    )
}
  1. That's mostly it! Now you can use useLocalStorageState in any other component. It will stay in sync as you dispatch updates, even across tabs
0.9.0

3 years ago

0.8.0

3 years ago

0.7.0

3 years ago

0.6.0

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago