You can check the official documentation & also following article,
so I won’t go into it further.
You need to use following React versions.
- react : 16.7.0-alpha.0
- react-dom : 16.7.0-alpha.0
It’s bleeding edge and not recommended to use in production.
You can follow along on CodeSandbox.
First, install the package, react-use-localstorage.
And use it in a “Functional Component”.
The demo shows that state is saved directly in local storage.
The source code is available on GitHub with MIT license.