diff --git a/examples/counter_functional/src/main.rs b/examples/counter_functional/src/main.rs index 926d5fc3a99..1fb79081b66 100644 --- a/examples/counter_functional/src/main.rs +++ b/examples/counter_functional/src/main.rs @@ -1,29 +1,28 @@ use yew::prelude::*; -// #[function_component] -// fn App() -> Html { -// let state = use_state(|| 0); -// -// let incr_counter = { -// let state = state.clone(); -// Callback::from(move |_| state.set(*state + 1)) -// }; -// -// let decr_counter = { -// let state = state.clone(); -// Callback::from(move |_| state.set(*state - 1)) -// }; -// -// html! { -// <> -//
{"current count: "} {*state}
-// -// -// > -// } -// } -fn main() { - let _d = html! { - +#[function_component] +fn App() -> Html { + let state = use_state(|| 0); + + let incr_counter = { + let state = state.clone(); + Callback::from(move |_| state.set(*state + 1)) + }; + + let decr_counter = { + let state = state.clone(); + Callback::from(move |_| state.set(*state - 1)) }; + + html! { + <> +{"current count: "} {*state}
+ + + > + } +} + +fn main() { + yew::Renderer::