Clone in a terminal:
lib.rs
benchmarks/yew/src/ - Morebench marks, speed this time
use wasm_bindgen::prelude::*; use yew::prelude::*; #[derive(Clone, PartialEq)] struct CounterState(u32); impl Reducible for CounterState { type Action = (); fn reduce(self: std::rc::Rc<Self>, _action: Self::Action) -> std::rc::Rc<Self> { std::rc::Rc::new(Self(self.0.saturating_add(1))) } } #[function_component(Counter)] fn counter() -> Html { let count = use_reducer(|| CounterState(0)); let onclick = { let count = count.clone(); Callback::from(move |_| count.dispatch(())) }; html! { <button id="counter" {onclick}>{format!("Clicks: {}", count.0)}</button> } } #[wasm_bindgen(start)] pub fn main() { yew::Renderer::<Counter>::new().render(); }

File history (2 commits)

ed76499 Johan Mattsson - johan.mattsson.m@gmail.com
Morebench marks, speed this time
Morebench marks, speed this time
b9a20cf Johan Mattsson - johan.mattsson.m@gmail.com
Benchmarks
Benchmarks

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112