Skip to content

NextJS: 'Box' cannot be used as a JSX component. #2430

@nesterow

Description

@nesterow

Describe the bug
The problems appear on next build and seem to be related to all theme-ui/Box components:

./src/components/cards/Post.tsx:33:18
Type error: 'Heading' cannot be used as a JSX component.
  Its return type 'ReactNode' is not a valid JSX element.

Screenshots
This is what might cause the error:

return <Component ref={ref} css={style} {...rest} />

image

'Component' cannot be used as a JSX component.
  Its element type 'ReactElement<any, any> | Component<any, any, any> | null' is not a valid JSX element.
    Type 'Component<any, any, any>' is not assignable to type 'Element | ElementClass | null'.
      Type 'Component<any, any, any>' is not assignable to type 'ElementClass'.
        The types returned by 'render()' are incompatible between these types.
          Type 'React.ReactNode' is not assignable to type 'import("/media/anton/Enterprise1/nesterov.digital/node_modules/@types/react/index").ReactNode'.
            Type 'ReactElement<any, string | JSXElementConstructor<any>>' is not assignable to type 'ReactNode'.
              Property 'children' is missing in type 'ReactElement<any, string | JSXElementConstructor<any>>' but required in type 'ReactPortal'.ts(2786)

Additional context

  • OS: Ubuntu 22.10
  • NodeJS v18.16.0
  • package.json:
    "next": "13.4.4"
    "@types/node": "20.2.5"
    "@types/react": "18.2.8"
    "@types/react-dom": "18.2.4"
    
  • tsconfig.json
    "jsxImportSource": "theme-ui",
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    releasedThis issue/pull request has been released.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions