Add state to function components.
Parameters:
-
initial
(StateT | Callable[[], StateT]
)
–
Initial state value or a function that returns the initial state value.
Returns:
-
tuple[StateT, Callable[[StateT], None]]
–
A tuple of the current state value and a function to update it.