useBreakpointEffect

useBreakpointEffect is a custom hook that executes a specific callback function when the breakpoint changes.

The current device is "mobile"

Usage

import { useBreakpointEffect } from "@yamada-ui/react"
const [device, setDevice] = useState("mobile")

useBreakpointEffect((breakpoint) => {
  if (breakpoint === "sm") {
    setDevice("mobile")
  } else if (breakpoint === "md") {
    setDevice("tablet")
  } else {
    setDevice("desktop")
  }
}, [])
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd
2nd