From 43ab9d01857d228600217310cfe492d53c8dedf0 Mon Sep 17 00:00:00 2001 From: Muhammad Hamza Date: Mon, 8 Aug 2022 23:41:03 +0500 Subject: [PATCH] This was not meant to be committed --- examples/counter_functional/src/main.rs | 49 ++++++++++++------------- 1 file changed, 24 insertions(+), 25 deletions(-) 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::::new().render(); }