Skip to content

useBoolean ​

Hook provides opportunity to manage boolean state

utilities
test coverage
Last changed: 7 days 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 ​

Source • Demo

Contributors ​

B
babin
babin
D
debabin
debabin

Released under the MIT License.