Merge branch 'master' into debug-signals

This commit is contained in:
Evan Almloff committed 2023-09-22 07:59:47 -05:00
commit 78860da006
434 files changed
+2673 -14238

No files matched your search

+16 -9
View File
@@ -1,15 +1,14 @@
use std::rc::Rc;
use dioxus_core::prelude::{
consume_context, consume_context_from_scope, current_scope_id, has_context, provide_context,
provide_context_to_scope, provide_root_context,
};
use dioxus_core::prelude::*;
use dioxus_core::ScopeId;
use generational_box::{
BorrowError, BorrowMutError, GenerationalBox, GenerationalRef, GenerationalRefMut, Owner, Store,
};
use crate::Effect;
fn current_store() -> Store {
match consume_context() {
Some(rt) => rt,
@@ -21,12 +20,20 @@ fn current_store() -> Store {
}
fn current_owner() -> Rc<Owner> {
match has_context() {
Some(rt) => rt,
None => {
let owner = Rc::new(current_store().owner());
provide_context(owner).expect("in a virtual dom")
match Effect::current() {
// If we are inside of an effect, we should use the owner of the effect as the owner of the value.
Some(effect) => {
let scope_id = effect.source;
owner_in_scope(scope_id)
}
// Otherwise either get an owner from the current scope or create a new one.
None => match has_context() {
Some(rt) => rt,
None => {
let owner = Rc::new(current_store().owner());
provide_context(owner).expect("in a virtual dom")
}
},
}
}