react-storage-helper
v1.0.15
Published
custom react hook for managing localstorage
Downloads
24
Readme
react-storage-helper
A custom React hook for managing data from localStorage easily.
Installation
npm install react-storage-helper
Usage
import React from 'react';
import useLocalStorage from 'react-storage-helper';
const MyComponent = () => {
const [data, setData, deleteData] = useLocalStorage('mySecret');
return (
<div>
<p>Data from localStorage: {data}</p>
<button onClick={() => setData('new value')}>Update Data</button>
<button onClick={deleteData}>Delete Data</button>
</div>
);
};
export default MyComponent;