drobs-local-storage-react
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

This package proposes a react hook to read and set value from/to local storage

--- Install --- npm install drobs-local-storage-react

--- Use --- Import package in your react app import useLocalStorage from 'drobs-local-storage-react';

add a state in your component with useLocalStorage (keyName, defaultValue) const [name, setName] = useLocalStorage('name', 'John Doe');

--- example --- 'use client';

import Image from "next/image"; import styles from "./page.module.css"; import useLocalStorage from 'drobs-local-storage-react';

export default function Home() { const [name, setName] = useLocalStorage('name', 'John Doe'); return (

Hello, {name}!

<input type="text" value={name} onChange={(e) => setName(e.target.value)} /> Vercel Logo
); }

Readme

Keywords

Package Sidebar

Install

npm i drobs-local-storage-react

Weekly Downloads

205

Version

1.1.3

License

ISC

Unpacked Size

4.94 kB

Total Files

6

Last publish

Collaborators

  • ddrobecq