Skip to content

Latest commit

History

History
24 lines (17 loc) 路 594 Bytes

File metadata and controls

24 lines (17 loc) 路 594 Bytes

useLocalStorage

Similar to useState but first arg is key to the value in local storage.

import { useLocalStorage } from '@ttrmz/react-utils'

Usage

const Example = () => {
  const [value, setValue] = useLocalStorage('key', 'initialValue')

  return <input value={value} onChange={(e) => setValue(e.target.value)} />
}

Parameters

Name Description Type
key local storage key String
initial value local storage initial value Any