How to use @rooks/use-localstorage - 2 common examples

To help you get started, we’ve selected a few @rooks/use-localstorage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imbhargav5 / rooks / packages / storybook / src / localstorage.js View on Github external
function UseLocalstorageDemo() {
  const [myValue, setMyValue, removeMyValue] = useLocalstorage("my-value", 0);
  return (
    <>
      <h1>Please check localstorage for changes</h1>
      <p>
        Value is {myValue}
        <button> setMyValue(myValue !== null ? myValue + 1 : 0)}&gt;
          Increment
        </button>
        <button>Remove </button>
      </p>
    
  );
}
github imbhargav5 / rooks / packages / storybook / src / localstorage.js View on Github external
function UseLocalstorageDemoObject() {
  const { value, set, remove } = useLocalstorage("my-value", 0);
  return (
    &lt;&gt;
      <h1>Please check localstorage for changes</h1>
      <p>
        Value is {value}
        <button> set(value !== null ? value + 1 : 0)}&gt;
          Increment
        </button>
        <button>Remove </button>
      </p>
    
  );
}

@rooks/use-localstorage

Local Storage hook for React

MIT
Latest version published 4 years ago

Package Health Score

56 / 100
Full package analysis

Popular @rooks/use-localstorage functions