Skip to content

Commit

Permalink
This was not meant to be committed
Browse files Browse the repository at this point in the history
  • Loading branch information
hamza1311 committed Aug 8, 2022
1 parent ea353cc commit 43ab9d0
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions 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! {
// <>
// <p @disabled={false}> {"current count: "} {*state} </p>
// <button onclick={incr_counter}> {"+"} </button>
// <button onclick={decr_counter}> {"-"} </button>
// </>
// }
// }

fn main() {
let _d = html! {
<div class={format!("fail{}", "")}></div>
#[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! {
<>
<p @disabled={false}> {"current count: "} {*state} </p>
<button onclick={incr_counter}> {"+"} </button>
<button onclick={decr_counter}> {"-"} </button>
</>
}
}

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

0 comments on commit 43ab9d0

Please sign in to comment.