UNPKG

@yamada-ui/react

Version:

React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion

1 lines 1.02 kB
{"version":3,"file":"use-update-breakpoint-effect.cjs","names":["useBreakpoint"],"sources":["../../../../src/hooks/use-breakpoint/use-update-breakpoint-effect.ts"],"sourcesContent":["import type { DependencyList } from \"react\"\nimport type { Breakpoint } from \"../../core\"\nimport { useUpdateEffect } from \"../../utils\"\nimport { useBreakpoint } from \"./use-breakpoint\"\n\n/**\n * `useUpdateBreakpointEffect` is a custom hook that skips the side effect on the initial render and executes a specific callback function when the breakpoint changes.\n *\n * @see https://yamada-ui.com/docs/hooks/use-update-breakpoint-effect\n */\nexport const useUpdateBreakpointEffect = (\n callback: (breakpoint: Breakpoint) => void,\n deps: DependencyList,\n) => {\n const breakpoint = useBreakpoint()\n\n useUpdateEffect(() => {\n callback(breakpoint)\n }, [breakpoint, ...deps])\n}\n"],"mappings":";;;;;;;;;AAUA,MAAa,6BACX,UACA,SACG;CACH,MAAM,aAAaA,sCAAe;AAElC,sCAAsB;AACpB,WAAS,WAAW;IACnB,CAAC,YAAY,GAAG,KAAK,CAAC"}