Switch todo!() to unreachable!/unimplemented! where it matters
This commit is contained in:
27 files changed
+73
-180
No files matched your search
@@ -8,7 +8,6 @@ fn app() -> Element {
|
||||
let mut value = use_signal(|| 0);
|
||||
let mut depth = use_signal(|| 0_usize);
|
||||
let items = use_memo(move || (0..depth()).map(|f| f as _).collect::<Vec<isize>>());
|
||||
|
||||
let state = use_memo(move || value() + 1);
|
||||
|
||||
println!("rendering app");
|
||||
|
||||
@@ -25,14 +25,12 @@ fn app() -> Element {
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn Component(a: i32, b: i32, c: i32, children: Element, onclick: EventHandler<()>) -> Element {
|
||||
fn Component(a: i32, b: i32, c: i32, children: Element, onclick: EventHandler) -> Element {
|
||||
rsx! {
|
||||
div { "{a}" }
|
||||
div { "{b}" }
|
||||
div { "{c}" }
|
||||
div { {children} }
|
||||
div {
|
||||
onclick: move |_| onclick.call(()),
|
||||
}
|
||||
div { onclick: move |_| onclick.call(()) }
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -15,7 +15,7 @@ fn app() -> Element {
|
||||
|
||||
// use_effect will subscribe to any changes in the signal values it captures
|
||||
// effects will always run after first mount and then whenever the signal values change
|
||||
use_effect(move || println!("Count changed to {}", count()));
|
||||
use_effect(move || println!("Count changed to {count}"));
|
||||
|
||||
// We can do early returns and conditional rendering which will pause all futures that haven't been polled
|
||||
if count() > 30 {
|
||||
@@ -49,7 +49,7 @@ fn app() -> Element {
|
||||
button { onclick: move |_| count += 1, "Up high!" }
|
||||
button { onclick: move |_| count -= 1, "Down low!" }
|
||||
button { onclick: move |_| running.toggle(), "Toggle counter" }
|
||||
button { onclick: move |_| saved_values.push(count().to_string()), "Save this value" }
|
||||
button { onclick: move |_| saved_values.push(count.to_string()), "Save this value" }
|
||||
button { onclick: move |_| saved_values.clear(), "Clear saved values" }
|
||||
|
||||
// We can do boolean operations on the current signal value
|
||||
@@ -71,6 +71,7 @@ fn app() -> Element {
|
||||
|
||||
// You can pass a value directly to any prop that accepts a signal
|
||||
Child { count: doubled_count() }
|
||||
Child { count: doubled_count }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ fn app() -> Element {
|
||||
|
||||
// use a for loop where the body itself is RSX
|
||||
for name in 0..10 {
|
||||
div {"{name}"}
|
||||
div { "{name}" }
|
||||
}
|
||||
|
||||
// Or even use an unterminated conditional
|
||||
|
||||
Reference in new issue
Block a user