diff --git a/editor/src/components/canvas/ui-jsx-canvas-renderer/ui-jsx-canvas-component-renderer.tsx b/editor/src/components/canvas/ui-jsx-canvas-renderer/ui-jsx-canvas-component-renderer.tsx index 463ad0f03d05..0e525092a52a 100644 --- a/editor/src/components/canvas/ui-jsx-canvas-renderer/ui-jsx-canvas-component-renderer.tsx +++ b/editor/src/components/canvas/ui-jsx-canvas-renderer/ui-jsx-canvas-component-renderer.tsx @@ -363,7 +363,7 @@ export function createComponentRendererComponent(params: { null, ) } - } else if (shouldUpdate()) { + } else if (shouldUpdate() || buildResult.current === null) { buildResult.current = buildComponentRenderResult(utopiaJsxComponent.rootElement) } return buildResult.current diff --git a/editor/src/core/workers/parser-printer/parser-printer-functional-components.spec.ts b/editor/src/core/workers/parser-printer/parser-printer-functional-components.spec.ts index 074cfdc2a759..9ccb167fcb3f 100644 --- a/editor/src/core/workers/parser-printer/parser-printer-functional-components.spec.ts +++ b/editor/src/core/workers/parser-printer/parser-printer-functional-components.spec.ts @@ -103,6 +103,14 @@ export var whatever = ({prop, ...otherProps}) => { } ` +const codeWithDestructuredPropsObjectWithElementNamePropAndRestParam = `import React from "react"; +export var whatever = ({As = 'div', ...otherProps}) => { + return ( + + ) +} +` + const codeWithDestructuredArray = `import React from "react"; import { View } from "utopia-api"; export var whatever = ([prop]) => { @@ -1059,6 +1067,10 @@ describe('Parsing, printing, reparsing a function component with props', () => { testParsePrintParse(codeWithDestructuredPropsObjectWithRestParam) }) + it('Correctly parses back and forth a destructured props object with element name prop and rest param', () => { + testParsePrintParse(codeWithDestructuredPropsObjectWithElementNamePropAndRestParam) + }) + it('Correctly parses back and forth a destructured props array', () => { testParsePrintParse(codeWithDestructuredArray) }) diff --git a/editor/src/core/workers/parser-printer/parser-printer-parsing.ts b/editor/src/core/workers/parser-printer/parser-printer-parsing.ts index 5e8e11121bbe..facc72f097fb 100644 --- a/editor/src/core/workers/parser-printer/parser-printer-parsing.ts +++ b/editor/src/core/workers/parser-printer/parser-printer-parsing.ts @@ -114,6 +114,7 @@ import { jsAssignmentStatement, clearAssignmentUniqueIDsAndSourceMaps, clearJSExpressionOtherJavaScriptUniqueIDs, + propertiesExposedByParams, } from '../../shared/element-template' import { maybeToArray, forceNotNull } from '../../shared/optional-utils' import type { @@ -4105,7 +4106,7 @@ export function parseOutFunctionContents( jsBlock = null } - let declared: Array = [...topLevelNames] + let declared: Array = [...topLevelNames, ...propertiesExposedByParams(params)] if (jsBlock != null) { declared.push(...jsBlock.definedWithin) }