From 33390ed150c33a51de3808663b9fc3c46c998de5 Mon Sep 17 00:00:00 2001 From: Dane Pilcher Date: Fri, 10 Sep 2021 07:30:54 -0600 Subject: [PATCH] feat: add react attr generation for collectionBindingProperties (#53) --- .../lib/react-component-render-helper.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/studio-ui-codegen-react/lib/react-component-render-helper.ts b/packages/studio-ui-codegen-react/lib/react-component-render-helper.ts index 2c90dcfc6..b2cedac6e 100644 --- a/packages/studio-ui-codegen-react/lib/react-component-render-helper.ts +++ b/packages/studio-ui-codegen-react/lib/react-component-render-helper.ts @@ -148,6 +148,7 @@ export function buildOpeningElementAttributes( prop.defaultValue === undefined ? buildCollectionBindingAttr(prop, propName) : buildCollectionBindingAttrWithDefault(prop, propName, prop.defaultValue); + return attr; } return factory.createJsxAttribute(factory.createIdentifier(propName), undefined); } @@ -155,9 +156,9 @@ export function buildOpeningElementAttributes( export function buildCollectionBindingAttr(prop: CollectionStudioComponentProperty, propName: string): JsxAttribute { const expr = prop.collectionBindingProperties.field === undefined - ? factory.createIdentifier(prop.collectionBindingProperties.property) + ? factory.createIdentifier('item') : factory.createPropertyAccessExpression( - factory.createIdentifier(prop.collectionBindingProperties.property), + factory.createIdentifier('item'), prop.collectionBindingProperties.field, ); @@ -176,9 +177,9 @@ export function buildCollectionBindingAttrWithDefault( const rightExpr = factory.createStringLiteral(defaultValue); const leftExpr = prop.collectionBindingProperties.field === undefined - ? factory.createIdentifier(prop.collectionBindingProperties.property) + ? factory.createIdentifier('item') : factory.createPropertyAccessExpression( - factory.createIdentifier(prop.collectionBindingProperties.property), + factory.createIdentifier('item'), prop.collectionBindingProperties.field, );