Переглянути джерело

Only check suspense if the component aborted rendering

Jonathan Kelley 1 рік тому
батько
коміт
cc984fae54
2 змінених файлів з 7 додано та 6 видалено
  1. 1 2
      packages/core/src/any_props.rs
  2. 6 4
      packages/core/src/scope_arena.rs

+ 1 - 2
packages/core/src/any_props.rs

@@ -1,11 +1,10 @@
-use std::{ panic::AssertUnwindSafe};
-
 use crate::{
     innerlude::Scoped,
     nodes::RenderReturn,
     scopes::{Scope, ScopeState},
     Element,
 };
+use std::panic::AssertUnwindSafe;
 
 /// A trait that essentially allows VComponentProps to be used generically
 ///

+ 6 - 4
packages/core/src/scope_arena.rs

@@ -83,10 +83,12 @@ impl VirtualDom {
             id: scope.id,
         });
 
-        if scope.suspended.get() {
-            self.suspended_scopes.insert(scope.id);
-        } else if !self.suspended_scopes.is_empty() {
-            _ = self.suspended_scopes.remove(&scope.id);
+        if matches!(allocated, RenderReturn::Aborted(_)) {
+            if scope.suspended.get() {
+                self.suspended_scopes.insert(scope.id);
+            } else if !self.suspended_scopes.is_empty() {
+                _ = self.suspended_scopes.remove(&scope.id);
+            }
         }
 
         // rebind the lifetime now that its stored internally