revert readme example to the simple counter
This commit is contained in:
1 parent
308226996c
commit
79501e43c1
1 file changed
-24
@@ -9,33 +9,9 @@ fn main() {
|
|||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
let mut count = use_signal(|| 0);
|
let mut count = use_signal(|| 0);
|
||||||
|
|
||||||
use_effect(move || {
|
|
||||||
println!("The count is now: {}", count);
|
|
||||||
});
|
|
||||||
|
|
||||||
rsx! {
|
rsx! {
|
||||||
h1 { "High-Five counter: {count}" }
|
h1 { "High-Five counter: {count}" }
|
||||||
Child { sig: count }
|
|
||||||
button { onclick: move |_| count += 1, "Up high!" }
|
button { onclick: move |_| count += 1, "Up high!" }
|
||||||
button { onclick: move |_| count -= 1, "Down low!" }
|
button { onclick: move |_| count -= 1, "Down low!" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
|
||||||
fn Child(sig: Signal<i32>) -> Element {
|
|
||||||
let doubled = use_memo(move || sig() * 2);
|
|
||||||
|
|
||||||
let tripled = use_async_memo(move || async move {
|
|
||||||
tokio::time::sleep(Duration::from_millis(200)).await;
|
|
||||||
sig() * 3
|
|
||||||
});
|
|
||||||
|
|
||||||
let trippled = use_memo(move || match tripled.value() {
|
|
||||||
Some(v) => v.cloned(),
|
|
||||||
None => 1338,
|
|
||||||
});
|
|
||||||
|
|
||||||
rsx! {
|
|
||||||
"The count is: {sig}, doubled: {doubled}, tripled: {trippled}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user