This content originally appeared on DEV Community and was authored by Saulo Dias
So I needed a simple way to use the sessionStorage
and localStorage
with React, and one of the requirements was to use TypeScript. The idea is pretty simple. It encapsulates the browser sessionStorage
or localStorage
with the useState
hook. The hooks actually return a stateful value, and a function to update it.
You can also customize the STORAGE_KEYS_PREFIX
, which can be useful to avoid conflicts between storage keys from different applications you might be developing.
This content originally appeared on DEV Community and was authored by Saulo Dias
Saulo Dias | Sciencx (2022-07-01T04:46:40+00:00) React hooks: useSessionStorage and useLocalStorage. Retrieved from https://www.scien.cx/2022/07/01/react-hooks-usesessionstorage-and-uselocalstorage/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.