@oneblink/apps-react
    Preparing search index...

    Function useBooleanState

    • This function is a react hook for boolean state that comes with useCallbacks for 'turning on', 'turning off' and toggling the state.

      The return type of useBooleanState(true) is an array where:

      • The first item is a boolean (the state).
      • The second item is () => void (a function that sets the state to true).
      • The third item is () => void (a function that sets the state to false).
      • The fourth item is () => void (a function that toggles the state to the opposite of what it currently is).

      As such, the items in the array can be destructured and named whatever you like:

      import { useBooleanState } from '@oneblink/apps-react'

      const [dialogIsOpen, openDialog, closeDialog, toggleDialog] =
      useBooleanState(true)

      These properties can then be used like:

      openDialog()
      closeDialog()
      toggleDialog()

      Parameters

      • defaultValue: boolean

      Returns [state: boolean, setTrue: () => void, setFalse: () => void, toggle: () => void]