Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@liuqiang1357/react-use-storage

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@liuqiang1357/react-use-storage

React Hook to handle local and session storage

latest
Source
npmnpm
Version
0.5.7
Version published
Maintainers
1
Created
Source

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)

Keywords

react

FAQs

Package last updated on 23 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts