fix props diffing

This commit is contained in:
Evan Almloff committed 2024-01-10 17:13:56 -06:00
1 parent 5b2b0c43bd
commit dc58212508
2 files changed
+4 -4

No files matched your search

+2 -2
View File
@@ -63,8 +63,8 @@ impl<P> VProps<P> {
impl<P: Clone + 'static> AnyProps for VProps<P> { impl<P: Clone + 'static> AnyProps for VProps<P> {
fn memoize(&self, other: &dyn Any) -> bool { fn memoize(&self, other: &dyn Any) -> bool {
match other.downcast_ref::<Self>() { match other.downcast_ref::<P>() {
Some(other) => (self.memo)(&self.props, &other.props), Some(other) => (self.memo)(&self.props, other),
None => false, None => false,
} }
} }
+2 -2
View File
@@ -72,11 +72,11 @@ impl VNode {
// copy out the box for both // copy out the box for both
let old_scope = &mut dom.scopes[scope_id.0]; 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(); 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 // 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 // This also implicitly drops the new props since they're not used
if old_props.memoize(new_props.props()) { if old_props.memoize(new_props.props()) {
tracing::trace!( tracing::trace!(