use_state
API
counterweight.hooks.use_state
PARAMETER | DESCRIPTION |
---|---|
initial_value |
The initial value of the state. It can either be the initial value itself, or a zero-argument function that returns the initial value.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
T
|
The current value of the state (i.e., for the current render cycle). |
Setter[T]
|
A function that can be called to update the value of the state (e.g., in an event handler). It can either be called with the new value of the state, or a function that takes the current value of the state and returns the new value of the state. If the value is not equal to the current of the state, Counterweight will trigger a render cycle. |