Browse Source

fix props diffing

Evan Almloff 1 year ago
parent
commit
dc58212508
2 changed files with 4 additions and 4 deletions
  1. 2 2
      packages/core/src/any_props.rs
  2. 2 2
      packages/core/src/diff/component.rs

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

@@ -63,8 +63,8 @@ impl<P> VProps<P> {
 
 impl<P: Clone + 'static> AnyProps for VProps<P> {
     fn memoize(&self, other: &dyn Any) -> bool {
-        match other.downcast_ref::<Self>() {
-            Some(other) => (self.memo)(&self.props, &other.props),
+        match other.downcast_ref::<P>() {
+            Some(other) => (self.memo)(&self.props, other),
             None => false,
         }
     }

+ 2 - 2
packages/core/src/diff/component.rs

@@ -72,11 +72,11 @@ impl VNode {
 
         // copy out the box for both
         let old_scope = &mut dom.scopes[scope_id.0];
-        let old_props = old_scope.props.deref();
+        let old_props: &dyn AnyProps = old_scope.props.deref();
         let new_props: &dyn AnyProps = new.props.deref();
 
         // If the props are static, then we try to memoize by setting the new with the old
-        // The target scopestate still has the reference to the old props, so there's no need to update anything
+        // The target ScopeState still has the reference to the old props, so there's no need to update anything
         // This also implicitly drops the new props since they're not used
         if old_props.memoize(new_props.props()) {
             tracing::trace!(