diff --git a/yew/src/html/scope.rs b/yew/src/html/scope.rs
index 12296c0195f..db7964ebed1 100644
--- a/yew/src/html/scope.rs
+++ b/yew/src/html/scope.rs
@@ -120,13 +120,17 @@ impl Scope {
node_ref: NodeRef,
props: COMP::Properties,
) -> Scope {
- *self.state.borrow_mut() = Some(ComponentState::new(
- element,
- ancestor,
- node_ref,
- self.clone(),
- props,
- ));
+ scheduler().push_comp(
+ ComponentRunnableType::Create,
+ Box::new(CreateComponent {
+ state: self.state.clone(),
+ element,
+ ancestor,
+ node_ref,
+ scope: self.clone(),
+ props,
+ }),
+ );
self.update(ComponentUpdate::Force, true);
self
}
@@ -219,13 +223,16 @@ impl Scope {
}
}
+type Dirty = bool;
+const DIRTY: Dirty = true;
+
struct ComponentState {
element: Element,
node_ref: NodeRef,
scope: Scope,
component: Box,
last_root: Option,
- rendered: bool,
+ render_status: Option,
}
impl ComponentState {
@@ -243,7 +250,37 @@ impl ComponentState {
scope,
component,
last_root: ancestor,
- rendered: false,
+ render_status: None,
+ }
+ }
+}
+
+struct CreateComponent
+where
+ COMP: Component,
+{
+ state: Shared