@shenglong/use-localstorage

Use localStorage with react hook

Usage no npm install needed!

<script type="module">
  import shenglongUseLocalstorage from 'https://cdn.skypack.dev/@shenglong/use-localstorage';
</script>

README

use-localstorage

A Hook for persisting state into localStorage.

Install

$ npm install --save @shenglong/use-localstorage

Or with Yarn

$ yarn add @shenglong/use-localstorage

Usage

import useLocalStorage from "@shenglong/use-localstorage"

function App() {
  const [name, setName] = useLocalStorage('name', 'Bob');

  return (
    <input
      type="text"
      placeholder="Enter your name"
      value={name}
      onChange={e => setName(e.target.value)}
    />
  )
}