Merge branch 'main' into isomorphic-spawn

This commit is contained in:
Evan Almloff committed 2024-03-11 15:42:47 -05:00
commit 3e9a360b55
22 files changed
+826 -931

No files matched your search

@@ -0,0 +1,30 @@
//! Signals can degrade into a ReadOnlySignal variant automatically
//! This is done thanks to a conversion by the #[component] macro
use dioxus::prelude::*;
fn main() {
launch(app);
}
fn app() -> Element {
let mut count = use_signal(|| 0);
rsx! {
h1 { "High-Five counter: {count}" }
button { onclick: move |_| count += 1, "Up high!" }
button { onclick: move |_| count -= 1, "Down low!" }
Child {
count,
"hiiii"
}
}
}
#[component]
fn Child(count: ReadOnlySignal<i32>, children: Element) -> Element {
rsx! {
div { "Count: {count}" }
{children}
}
}
+1 -1
View File
@@ -12,7 +12,7 @@ use crate::{CopyValue, Readable, Writable};
/// When a signal calls .read(), it will look for the current ReactiveContext to read from.
/// If it doesn't find it, then it will try and insert a context into the nearest component scope via context api.
///
/// When the ReactiveContext drops, it will remove itself from the the associated contexts attached to signal
/// When the ReactiveContext drops, it will remove itself from the associated contexts attached to signal
#[derive(Clone, Copy, PartialEq, Eq)]
pub struct ReactiveContext {
inner: CopyValue<Inner, SyncStorage>,