Skip to content

bug: cannot be used as a JSX component #621

Open
@masoudjapalaghi

Description

@masoudjapalaghi

Prerequisites

Stencil Version

^4.22.3

Stencil Framework Output Target

React

Stencil Framework Output Target Version

^0.8.2

Current Behavior

'MyComponent' cannot be used as a JSX component.
Its type 'StencilReactComponent<MyComponent, MyComponentEvents>' is not a valid JSX element type.
Type 'ForwardRefExoticComponent<Omit<HTMLAttributes, keyof MyComponentEvents | "age" | "favoriteKidName" | "first" | "kidsNames" | "last" | "middle"> & EventListeners<...> & Partial<...> & RefAttributes<...>>' is not assignable to type '(props: any) => ReactNode | Promise'.
Type 'ReactNode' is not assignable to type 'ReactNode | Promise'.
Type 'ReactElement<any, string | JSXElementConstructor>' is not assignable to type 'ReactNode | Promise'.
Property 'children' is missing in type 'ReactElement<any, string | JSXElementConstructor>' but required in type 'ReactPortal'.ts(2786)
index.d.ts(387, 9): 'children' is declared here.

Expected Behavior

Fix error to perform build

The exact same config without hydrate is working correctly on react.

Steps to Reproduce

reactOutputTarget({
stencilPackageName: "..",
customElementsDir: "web-components",
outDir: "../../packages/component-library/react",
}),//worked

reactOutputTarget({
stencilPackageName: "..",
customElementsDir: "web-components",
outDir: "../../packages/component-library/next",
hydrateModule: "../hydrate",
}),//thrrow error

{
type: "dist-custom-elements",
externalRuntime: false,
dir: "../../packages/component-library/web-components",
},
{
type: "dist-hydrate-script",
dir: "../../packages/component-library/hydrate",
},


error: 'MyComponent' cannot be used as a JSX component.
Its type 'StencilReactComponent<MyComponent, MyComponentEvents>' is not a valid JSX element type.
Type 'ForwardRefExoticComponent<Omit<HTMLAttributes, keyof MyComponentEvents | "age" | "favoriteKidName" | "first" | "kidsNames" | "last" | "middle"> & EventListeners<...> & Partial<...> & RefAttributes<...>>' is not assignable to type '(props: any) => ReactNode | Promise'.
Type 'ReactNode' is not assignable to type 'ReactNode | Promise'.
Type 'ReactElement<any, string | JSXElementConstructor>' is not assignable to type 'ReactNode | Promise'.
Property 'children' is missing in type 'ReactElement<any, string | JSXElementConstructor>' but required in type 'ReactPortal'.ts(2786)
index.d.ts(387, 9): 'children' is declared here.

Code Reproduction URL

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wanteda good issue for the communitytype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions