useState

fun <T> ComponentScope.useState(initializer: () -> T): State<T>

Declares a state variable within a Component. The initializer will provide the initial value if it hasn't already been initialized in a previous render of the Component.

Assignments to the state variables are allowed only in updateState block to batch updates and trigger a UI layout only once per batch.