https://github.com/progfay/use-session-storage
React hooks to manage state that works with `sessionStorage`
https://github.com/progfay/use-session-storage
react react-hooks sessionstorage
Last synced: 3 months ago
JSON representation
React hooks to manage state that works with `sessionStorage`
- Host: GitHub
- URL: https://github.com/progfay/use-session-storage
- Owner: progfay
- License: mit
- Created: 2023-07-17T06:39:15.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-24T16:30:39.000Z (almost 2 years ago)
- Last Synced: 2025-01-30T20:15:58.422Z (5 months ago)
- Topics: react, react-hooks, sessionstorage
- Language: TypeScript
- Homepage: https://developer.mozilla.org/ja/docs/Web/API/Window/sessionStorage
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## `useSessionStorage(key)` hooks
__⚠️ This code has not yet been published in npm registry.__
```tsx
import {
setSessionStorageItem,
useSessionStorage,
} from '@progfay/use-session-storage'const KEY = 'RANDOM_VALUE'
const ComponentA = () => (
setSessionStorageItem(Math.random().toFixed(10))}>
Set random value for sessionStorage
)const ComponentB = () => {
const randomValue = useSessionStorage(KEY)
return (
random value in sessionStorage: {randomValue}
)
}const App = () => (
<>
>
)
```