Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@shenglong/use-localstorage

shenglongy5MIT1.0.0TypeScript support: included

Use localStorage with react hook

localStorage, react, hooks

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)}
    />
  )
}