UNPKG

@yamada-ui/react

Version:

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

24 lines (20 loc) 600 B
"use client"; import { useCallback, useState } from "react"; //#region src/hooks/use-boolean/index.ts /** * `useBoolean` is a custom hook used to manage boolean values using `on`, `off`, and `toggle` functions. * * @see https://yamada-ui.com/docs/hooks/use-boolean */ const useBoolean = (init = false) => { const [flg, setFlg] = useState(init); const on = useCallback(() => setFlg(true), []); return [flg, { off: useCallback(() => setFlg(false), []), toggle: useCallback(() => setFlg((prev) => !prev), []), on }]; }; //#endregion export { useBoolean }; //# sourceMappingURL=index.js.map