pub fn use_state<T>(
    hooks: &mut Hooks<'_>,
    init: T
) -> (T, Arc<CbDebuggable<dyn Fn(T) + Sync + Send>>)
where T: Clone + Debug + Send + 'static,
Expand description

Preserve state between rerenders.

The state can be mutated by the setter, which will re-render the origin Element.

Note: The new value set by the returned setter won’t be visible until the next re-render.

let (value, setter) = use_state(hooks,5);

setter(7);

println!("{value}"); // Prints 5