fix infinite recursion in reactive context

This commit is contained in:
Evan Almloff committed 2024-02-05 07:23:32 -06:00
1 parent 26378631e0
commit 26e4651e9f
2 files changed
+7 -4

No files matched your search

+5 -2
View File
@@ -19,7 +19,7 @@ pub struct ReactiveContext {
} }
thread_local! { thread_local! {
static CURRENT: RefCell<Vec<ReactiveContext>> = RefCell::new(vec![]); static CURRENT: RefCell<Vec<ReactiveContext>> = const { RefCell::new(vec![]) };
} }
impl ReactiveContext { impl ReactiveContext {
@@ -42,7 +42,10 @@ impl ReactiveContext {
}; };
let mut self_ = Self { let mut self_ = Self {
inner: CopyValue::new_maybe_sync(inner), inner: CopyValue::new_maybe_sync_in_scope(
inner,
scope.or_else(current_scope_id).unwrap(),
),
}; };
self_.inner.write().self_ = Some(self_); self_.inner.write().self_ = Some(self_);
+2 -2
View File
@@ -55,8 +55,8 @@ fn set_owner<S: AnyStorage>(owner: Option<Owner<S>>) -> Option<Owner<S>> {
} }
thread_local! { thread_local! {
static SYNC_OWNER: RefCell<Option<Owner<SyncStorage>>> = RefCell::new(None); static SYNC_OWNER: RefCell<Option<Owner<SyncStorage>>> = const { RefCell::new(None) };
static UNSYNC_OWNER: RefCell<Option<Owner<UnsyncStorage>>> = RefCell::new(None); static UNSYNC_OWNER: RefCell<Option<Owner<UnsyncStorage>>> = const { RefCell::new(None) };
} }
fn current_owner<S: Storage<T>, T>() -> Owner<S> { fn current_owner<S: Storage<T>, T>() -> Owner<S> {