Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/progfay/use-local-storage

React hooks to manage state that works with `localStorage`
https://github.com/progfay/use-local-storage

localstorage react react-hooks

Last synced: 6 days ago
JSON representation

React hooks to manage state that works with `localStorage`

Awesome Lists containing this project

README

        

## `useLocalStorage(key)` hooks

__⚠️ This code has not yet been published in npm registry.__

```tsx
import {
setlocalStorageItem,
useLocalStorage,
} from '@progfay/use-local-storage'

const KEY = 'RANDOM_VALUE'

const ComponentA = () => (
setLocalStorageItem(Math.random().toFixed(10))}>
Set random value for localStorage

)

const ComponentB = () => {
const randomValue = useLocalStorage(KEY)
return (


random value in localStorage: {randomValue}


)
}

const App = () => (
<>


>
)
```