Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 678 Bytes

useBoolean.md

File metadata and controls

27 lines (19 loc) · 678 Bytes

useBoolean

🔍 Overview

The useBoolean hook is a custom React hook designed for managing boolean states within functional components. It provides an easy and intuitive way to toggle a boolean value or to explicitly set it to true or false.

function useBoolean(
  defaultValue?: boolean
): [boolean, () => void, () => void, () => void]
function useBoolean(defaultValue = false): [bool, toggle, setTrue, setFalse]

💡 Example

import { useBoolean } from '@kim-elijah-sol/react-useful-hooks'

function Component() {
    const [isAutoLogin, toggleAutoLogin, checkAutoLogin, uncheckAutoLogin] = useBoolean()

    ...
}