diff --git a/src/runtime/component_node.ts b/src/runtime/component_node.ts index 911eeccf..d020e475 100644 --- a/src/runtime/component_node.ts +++ b/src/runtime/component_node.ts @@ -30,15 +30,15 @@ export function useComponent(): Component { /** * Apply default props (only top level). - * - * Note that this method does modify in place the props */ -function applyDefaultProps
(props: P, defaultProps: Partial
) { +function applyDefaultProps
(props: P, defaultProps: Partial
): P { + const result = Object.create(props); for (let propName in defaultProps) { - if ((props as any)[propName] === undefined) { - (props as any)[propName] = defaultProps[propName]; + if (props[propName] === undefined) { + result[propName] = defaultProps[propName]; } } + return result; } // ----------------------------------------------------------------------------- // Integration with reactivity system (useState) @@ -106,7 +106,7 @@ export function component
( if (shouldRender) { node.forceNextRender = false; } else { - const currentProps = node.component.props; + const currentProps = node.props; shouldRender = parentFiber.deep || arePropsDifferent(currentProps, props); } if (shouldRender) { @@ -148,6 +148,7 @@ export class ComponentNode
implements VNode