react-use-localstorage-hook

1.2.5 • Public • Published

react-use-localstorage-hook npm version

Simple localstorage hook with sharing states across components, tabs, windows

npm i react-use-localstorage-hook

Example of code:

import useLocalStorage from "react-use-localstorage-hook";
 
function Input() {
  const [value, setValue] = useLocalStorage("test:input", "input text");
 
  return (
    <>
      <div>{value}</div>
      <input
        value={value}
        onInput={({ target: { value } }) => setValue(value)}
      />
    </>
  );
}

Advanced example in this demo:
Edit React useLocalStorage hook

/react-use-localstorage-hook/

    Package Sidebar

    Install

    npm i react-use-localstorage-hook

    Weekly Downloads

    53

    Version

    1.2.5

    License

    MIT

    Unpacked Size

    20.3 kB

    Total Files

    11

    Last publish

    Collaborators

    • vovastradamus