useLocalStorage
useLocalStorage
is a custom hook for storing, updating, and retrieving values in local storage.
Import
import { useLocalStorage } from "@yamada-ui/react"
Usage
Editable example
const [value, setValue, resetValue] = useLocalStorage<number>({ key: "value", defaultValue: 1, }) return ( <Wrap gap="md"> <Button onClick={() => setValue((prev) => prev + 1)}> Current Local Storage value: {value} </Button> <Button colorScheme="danger" onClick={resetValue}> Reset Local Storage value </Button> </Wrap> )
Edit this page on GitHub