1 unstable release
0.1.0 | Nov 25, 2022 |
---|
#20 in #redux
66KB
1.5K
SLoC
Yewdux
Ergonomic state management for Yew applications.
See the book for more details.
Example
use yew::prelude::*;
use yewdux::prelude::*;
#[derive(Default, Clone, PartialEq, Eq, Store)]
struct State {
count: u32,
}
#[function_component]
fn App() -> Html {
let (state, dispatch) = use_store::<State>();
let onclick = dispatch.reduce_mut_callback(|state| state.count += 1);
html! {
<>
<p>{ state.count }</p>
<button {onclick}>{"+1"}</button>
</>
}
}
fn main() {
yew::Renderer::<App>::new().render();
}
Dependencies
~13–22MB
~305K SLoC