Skip to main content

useToggle

Callable

  • useToggle(initialValue?: boolean): readonly [value: boolean, toggle: () => void]

  • Returns a tuple containing a boolean value and a function that toggles its value. The initial boolean value defaults to false if not provided.


    Parameters

    • optionalinitialValue: boolean = false

      The initial value of the boolean.

    Returns readonly [value: boolean, toggle: () => void]

    A tuple containing the boolean value and a function that toggles its value.