Home

Awesome

seed_hooks: Local state for seed apps

seed_hooks is a crate that allows you to store state on a per component basis in your seed apps. It is designed as a clone of React Hooks, principally the useState hook.

Here a component is defined as a 'topological aware execution context', this means that the component is aware of its own call-site identity and location in the call tree.

Example:

This is a complete counting button with state implemented in in the Seed framework:

use seed_hooks::*;

#[topo::nested]
fn my_button() -> Node<Msg> {
    let count = use_state(|| 0);

    div![
        count.get(),
        button![count.mouse_ev(Ev::Click, |count, _| *count += 1), "Click me"],
    ]
}

The two most important functions are:

How does it work?