Leave Yamada UI a star

Star
Yamada UIYamada UIv1.6.4

useLocalStorage

useLocalStorage is a custom hook for storing, updating, and retrieving values in local storage.

Source@yamada-ui/use-local-storage

Import

import { useLocalStorage } from "@yamada-ui/react"
Copied!

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>
)
Copied!

Edit this page on GitHub

PrevioususeLoadingNextuseMediaQuery