diff --git a/examples/readme.rs b/examples/readme.rs index bf7c31fa3..7c5240086 100644 --- a/examples/readme.rs +++ b/examples/readme.rs @@ -12,42 +12,11 @@ fn main() { } fn app() -> Element { - let mut vec = use_signal(|| vec![1, 2, 3]); - - let len = vec.len(); - - println!("app len: {}", len); - use_effect(move || { - println!("app effect len: {}", vec.len()); - }); + let mut count = use_signal(|| 0); rsx! { - button { - onclick: move |_| { - let mut vec = vec.write(); - vec.push(len); - }, - "Add" - } - button { - onclick: move |_| { - vec.pop(); - }, - "Remove" - } - for i in 0..len { - Child { - index: i, - vec, - } - } - } -} - -#[component] -fn Child(index: usize, vec: Signal>) -> Element { - let item = use_memo(move || vec.read()[index]); - rsx! { - div { "Item: {item}" } + h1 { "High-Five counter: {count}" } + button { onclick: move |_| count += 1, "Up high!" } + button { onclick: move |_| count -= 1, "Down low!" } } }