@liuqiang1357/react-use-storage
TypeScript icon, indicating that this package has built-in type declarations

0.5.7 • Public • Published

react-use-storage

React Hook to handle local and session storage


Install

npm install --save react-use-storage

Usage

See this hooks as a useState hooks that syncs with local/session storage.

☝️ NOTE: if the value of the key in the storage change from another portion of your code, the hook keep it in sync and re-render your component with the new value.

LocalStorage

	import {useLocalStorage} from "react-use-storage";

	// ...
		const [value, setValue, removeValue] = useLocalStorage("key", "default value");

SessionStorage

	import {useSessionStorage} from "react-use-storage";

	// ...
		const [value, setValue, removeValue] = useSessionStorage("key", "default value");

License

UNLICENSED (public domain)

Package Sidebar

Install

npm i @liuqiang1357/react-use-storage

Weekly Downloads

12

Version

0.5.7

License

UNLICENSE

Unpacked Size

10.2 kB

Total Files

6

Last publish

Collaborators

  • liuqiang1357