Skip to content

useBoolean

Hook provides opportunity to manage boolean state

state
necessary
test coverage
Last changed: 6 months ago

Installation

Library
CLI
Manual
typescript
import { useBoolean } from '@siberiacancode/reactuse';

Usage

typescript
const [on, toggle] = useBoolean()
## Demo

Api

Parameters

NameTypeDefaultNote
initialValue?booleanfalseThe initial boolean value

Returns

UseBooleanReturn

Type declaration

typescript
export type UseBooleanReturn = [
  /** The current boolean state value */
  value: boolean,
  /** Function to toggle the boolean state */
  toggle: (value?: boolean) => void
];

Source

SourceDemo

Contributors

D
debabin
debabin
B
babin
babin

Released under the MIT License.