Skip to content

This custom hook can substitute the useState hook when needed to perform data persisting between page reload or even browser reload.

Notifications You must be signed in to change notification settings

iNikolas/custom-hooks-data-persisting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The custom hook for data persisting into browser local storage so that after page reload they still will be present. The hook is multipurpose, you can simply copy them "as is" and utilize them for the most varied aims in your React application. The most lovely is that our custom hook posesses the same format as a useState hook if we do not consider that we need to pass additionaly "key" as a reference for our variable into browser local storage.

Don't forget to use the prefix "use" before each custom hook as a convention. Data into localStorage persists even after browser reload. If you are not willing such behavior you can use sessionStorage instead - the data will be saved only after page reload.

About

This custom hook can substitute the useState hook when needed to perform data persisting between page reload or even browser reload.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published