fix merge errors

This commit is contained in:
Evan Almloff committed 2024-01-02 14:55:46 -06:00
1 parent cddcd69200
commit 73b7f450a5
5 files changed
+45 -145

No files matched your search

-28
View File
@@ -1,28 +0,0 @@
use dioxus::prelude::*;
use dioxus_signals::*;
fn main() {
dioxus_desktop::launch(App);
}
#[component]
fn App(cx: Scope) -> Element {
let signal = use_signal(cx, || vec![String::from("Hello"), String::from("World")]);
render! {
button {
onclick: move |_| {
signal.write().push(String::from("Hello"));
},
"Add one"
}
for item in signal.iter_signals() {
Child { signal: item }
}
}
}
#[component]
fn Child(cx: Scope, signal: MappedSignal<String>) -> Element {
render! {"{signal:?}"}
}
-39
View File
@@ -1,39 +0,0 @@
use dioxus::prelude::*;
use dioxus_signals::*;
fn main() {
dioxus_desktop::launch(App);
}
#[component]
fn App(cx: Scope) -> Element {
let signal = use_signal(cx, || Some(String::from("Hello")));
render! {
button {
onclick: move |_| {
let new_value = (!signal.read().is_some()).then(|| String::from("Hello"));
signal.set(new_value);
},
"Swap"
}
button {
onclick: move |_| {
if let Some(value) = &mut *signal.write() {
value.push_str(" World");
}
},
"Change"
}
if let Some(item) = signal.as_mapped_ref() {
render! {
Child { signal: item }
}
}
}
}
#[component]
fn Child(cx: Scope, signal: MappedSignal<String>) -> Element {
render! {"{signal:?}"}
}