From 787fac8827a58c209df7bca5a13f3b4ff82a148f Mon Sep 17 00:00:00 2001 From: Wes Reid Date: Tue, 5 Aug 2025 15:37:35 -0700 Subject: [PATCH] Update Gen 2 React with BuilderBlocks CustomHero component --- .../src/snippet-tests/custom-child.spec.ts | 7 +--- .../react/src/components/CustomHero.tsx | 38 +++++++++++-------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/packages/sdks-tests/src/snippet-tests/custom-child.spec.ts b/packages/sdks-tests/src/snippet-tests/custom-child.spec.ts index cfde1ecdb61..592bba22866 100644 --- a/packages/sdks-tests/src/snippet-tests/custom-child.spec.ts +++ b/packages/sdks-tests/src/snippet-tests/custom-child.spec.ts @@ -40,10 +40,7 @@ test.describe('Div with Hero class, and text', () => { const builderBlock = page.locator('div.builder-block').first(); await expect(builderBlock).toBeVisible(); - const column1Text = page.locator('text=This is text from your component'); - await expect(column1Text).toBeVisible(); - - const column2Text = page.locator('text=This is Builder text'); - await expect(column2Text).toBeVisible(); + const componentText = page.locator('text=This is text from your component'); + await expect(componentText).toBeVisible(); }); }); diff --git a/packages/sdks/snippets/react/src/components/CustomHero.tsx b/packages/sdks/snippets/react/src/components/CustomHero.tsx index e81502fbb75..f3456bab692 100644 --- a/packages/sdks/snippets/react/src/components/CustomHero.tsx +++ b/packages/sdks/snippets/react/src/components/CustomHero.tsx @@ -1,34 +1,40 @@ -import { RegisteredComponent } from '@builder.io/sdk-react'; -import { ReactNode } from 'react'; +import { + Blocks, + BuilderBlock, + RegisteredComponent, +} from '@builder.io/sdk-react'; interface CustomHeroProps { - children: ReactNode; + content: BuilderBlock[]; + builderBlock: BuilderBlock; } const CustomHero = (props: CustomHeroProps) => { return ( <> -
This is text from your component
+

This is text from your component

- {props.children} + ); }; export const customHeroInfo: RegisteredComponent = { - component: CustomHero, name: 'CustomHero', - inputs: [], - canHaveChildren: true, - defaultChildren: [ + component: CustomHero, + shouldReceiveBuilderProps: { + builderBlock: true, + }, + inputs: [ { - '@type': '@builder.io/sdk:Element', - component: { - name: 'Text', - options: { - text: 'This is Builder text', - }, - }, + name: 'content', + type: 'uiBlocks', + hideFromUI: true, + defaultValue: [], }, ], };