10 releases

new 0.11.0 Mar 7, 2025
0.10.0 Dec 19, 2023
0.9.4 Oct 10, 2023
0.9.3 Jun 1, 2023
0.9.0 Nov 25, 2022

#1496 in WebAssembly

Download history 516/week @ 2024-11-17 752/week @ 2024-11-24 795/week @ 2024-12-01 1042/week @ 2024-12-08 802/week @ 2024-12-15 320/week @ 2024-12-22 148/week @ 2024-12-29 653/week @ 2025-01-05 883/week @ 2025-01-12 845/week @ 2025-01-19 736/week @ 2025-01-26 1100/week @ 2025-02-02 1314/week @ 2025-02-09 901/week @ 2025-02-16 884/week @ 2025-02-23 656/week @ 2025-03-02

3,919 downloads per month
Used in 9 crates (via yewdux)

MIT/Apache

7KB
122 lines

Yewdux

Ergonomic state management for Yew applications.

See the book for more details.

Example

use yew::prelude::*;
use yewdux::prelude::*;

#[derive(Default, Clone, PartialEq, Store)]
struct State {
    count: u32,
}

#[function_component]
fn ViewCount() -> Html {
    let (state, _) = use_store::<State>();
    html!(state.count)
}

#[function_component]
fn IncrementCount() -> Html {
    let (_, dispatch) = use_store::<State>();
    let onclick = dispatch.reduce_mut_callback(|counter| counter.count += 1);

    html! {
        <button {onclick}>{"+1"}</button>
    }
}

#[function_component]
fn App() -> Html {
    html! {
        <>
        <ViewCount />
        <IncrementCount />
        </>
    }
}

fn main() {
    yew::Renderer::<App>::new().render();
}

Dependencies

~0.6–1MB
~23K SLoC