Leave Yamada UI a star

Star
Yamada UIYamada UIv1.7.2

usePrevious

usePrevious is a custom hook for obtaining the previous value.

Source@yamada-ui/use-previous

Import

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

Usage

Editable example

const [flg, { toggle }] = useBoolean()

const prevFlg = usePrevious(flg)

return (
  <>
    <Text>
      state: {String(flg)}, prev: {String(prevFlg)}
    </Text>

    <Button mt="md" onClick={toggle}>
      Click me to toggle the boolean value
    </Button>
  </>
)
Copied!

Edit this page on GitHub

PrevioususeOutsideClickNextuseProcessing