mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-26 22:20:19 +00:00
restore readme
This commit is contained in:
parent
fc7efd8006
commit
48f845985b
1 changed files with 4 additions and 35 deletions
|
@ -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<Vec<usize>>) -> 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!" }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue