import { useLocalStorage } from "https://deno.land/x/netzo@0.5.70/deps/usehooks-ts.ts";
Custom hook for using local storage to persist state across page reloads.
Examples
const [count, setCount] = useLocalStorage('count', 0);
// Access the count
value and the setCount
function to update it.
const [count, setCount] = useLocalStorage('count', 0);
// Access the count
value and the setCount
function to update it.
Parameters
- The initial value of the state or a function that returns the initial value.
optional
options: UseLocalStorageOptions<T>- Options for customizing the behavior of serialization and deserialization (optional).
Returns
[T, Dispatch<SetStateAction<T>>]
A tuple containing the stored value and a function to set the value.