Provides utilities for localStorage
and sessionStorage
useStateWithSessionStorage
import { useStateWithSessionStorage } from "mui-extended"; // In a function component // ... const [state, setState, checked] = useStateWithSessionStorage( "sessionStorageKey", // any unique key to use in store "initialValue" // uses type generics same as `useState` );
useStateWithLocalStorage
import { useStateWithLocalStorage } from "mui-extended"; // In a function component // ... const [state, setState, checked] = useStateWithLocalStorage( "localStorageKey", // any unique key to use in store "initialValue" // uses type generics same as `useState` );
This Demo uses useStateWithSessionStorage
to persist navigation menu's expansion state across page reloads
Write an email to opensource@sodaru.com