MCPcopy Create free account
hub / github.com/cosdensolutions/code / Demo

Function Demo

videos/long/custom-react-hooks-useLocalStorage/index.tsx:5–26  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import { useLocalStorage } from './useLocalStorage';
4
5const Demo = () => {
6 const [value, setValue] = useState('');
7
8 const { getItem, setItem, removeItem } = useLocalStorage('value');
9
10 return (
11 <div className='tutorial-shorts'>
12 <h1 className='mb-2 text-3xl font-bold'>useLocalStorage</h1>
13 <input
14 className='mb-4'
15 type='text'
16 value={value}
17 onChange={(e) => setValue(e.target.value)}
18 />
19 <div className='flex flex-row gap-4'>
20 <button onClick={() => setItem(value)}>Set</button>
21 <button onClick={() => console.log(getItem())}>Get</button>
22 <button onClick={removeItem}>Remove</button>
23 </div>
24 </div>
25 );
26};
27
28export default Demo;

Callers

nothing calls this directly

Calls 3

useLocalStorageFunction · 0.90
setItemFunction · 0.70
getItemFunction · 0.70

Tested by

no test coverage detected