MUI Extended UI Components

Web Storage


Provides utilities for localStorage and sessionStorage

Usage

  • 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

Does this page need improvements?
Edit This Page in GitHub
Did this page help you?
Provide feedback in the GitHub Discussion Page
Need More help?

Write an email to opensource@sodaru.com