Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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

);
};
```