diff --git a/example-project/component-library-react/src/components.server.ts b/example-project/component-library-react/src/components.server.ts index d50c86b4..fb95bca4 100644 --- a/example-project/component-library-react/src/components.server.ts +++ b/example-project/component-library-react/src/components.server.ts @@ -1,5 +1,3 @@ -'use client'; - /** * This file was automatically generated by the Stencil React Output Target. * Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. diff --git a/packages/react/src/create-stencil-react-components.test.ts b/packages/react/src/create-stencil-react-components.test.ts index fec67fb5..653984ae 100644 --- a/packages/react/src/create-stencil-react-components.test.ts +++ b/packages/react/src/create-stencil-react-components.test.ts @@ -252,7 +252,7 @@ describe('createStencilReactComponents', () => { clientModule: './client', }); - expect(result).toContain(`'use client';`); + expect(result).not.toContain(`'use client';`); expect(result).toContain(`// @ts-ignore - ignore potential type issues as the project is importing itself`); expect(result).toContain(`import * as clientComponents from "./client";`); expect(result).toContain(`from '@stencil/react-output-target/ssr'`); diff --git a/packages/react/src/create-stencil-react-components.ts b/packages/react/src/create-stencil-react-components.ts index ef1594ae..2cfb27e1 100644 --- a/packages/react/src/create-stencil-react-components.ts +++ b/packages/react/src/create-stencil-react-components.ts @@ -32,7 +32,7 @@ export const createStencilReactComponents = ({ * automatically attach the `use client` directive if we are not generating * server side rendering components. */ - const useClientDirective = `'use client';\n\n`; + const useClientDirective = hydrateModule ? '' : `'use client';\n\n`; const autogeneratedComment = `/** * This file was automatically generated by the Stencil React Output Target. * Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.