Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vikyw89/swr-sync-state
a small library to wrap SWR, enabling SWR to function as global state manager
https://github.com/vikyw89/swr-sync-state
Last synced: about 1 month ago
JSON representation
a small library to wrap SWR, enabling SWR to function as global state manager
- Host: GitHub
- URL: https://github.com/vikyw89/swr-sync-state
- Owner: vikyw89
- License: mit
- Created: 2023-05-18T04:05:03.000Z (over 1 year ago)
- Default Branch: dev
- Last Pushed: 2023-05-20T04:06:53.000Z (over 1 year ago)
- Last Synced: 2024-10-11T08:41:40.591Z (2 months ago)
- Language: JavaScript
- Size: 109 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# swr-sync-state
a small library to wrap SWR, enabling SWR to function as global state manager
## to start
```jsx
npm i swr-sync-state
```## usage
```jsx
// inside react component
export const SomeComponent = () => {
const key = 'someKey';
const state = useSyncSWR(key) ?? 0;const incrementHandler = () => {
setSyncSWR(key, (p) => (p ?? 0) + 1);
};return (
Counter : {state}
Increment
);
};
```