Skip to content

use_state

use_state #

use_state(
    initial: StateT | Callable[[], StateT],
) -> tuple[StateT, Callable[[StateT], None]]

Add state to function components.

PARAMETER DESCRIPTION
initial

Initial state value or a function that returns the initial state value.

TYPE: StateT | Callable[[], StateT]

RETURNS DESCRIPTION
tuple[StateT, Callable[[StateT], None]]

A tuple of the current state value and a function to update it.