yewdux 0.13.0

Ergonomic state management for Yew applications
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use yew::prelude::*;

use crate::context;

#[derive(PartialEq, Clone, Properties)]
pub struct Props {
    pub children: Children,
}

#[function_component]
pub fn YewduxRoot(Props { children }: &Props) -> Html {
    let ctx = use_state(context::Context::new);
    html! {
        <ContextProvider<context::Context> context={(*ctx).clone()}>
            { children.clone() }
        </ContextProvider<context::Context>>
    }
}