React Custom Hook useLocalStorage

React Hooks have taken the world by storm! No need for clunky classes and weird quirks about the keyword this. Now we can use hooks and customize how we tap into the React component lifecycle.

import { useState } from 'react';

useLocalStorage is a wrapper around the useState and window.localStorage api. So it acts just like useState.

There are many packages with custom hooks that I suggest you look at, if you don’t want to implement them on your own.

Happy React coding!!!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store