Skip to content

JSX element type 'string' is not a constructor function for JSX elements. #30108

Closed
@nmain

Description

@nmain

TypeScript Version: 3.4.0-dev.20190226

Search Terms:
JSX element constructor function

Code

import * as React from "react";

function Foobaz() {
    return "Foobaz";
}
<Foobaz />;

Expected behavior:
Code compiles. This is a basic functional component that always returns a string, one of the valid things that React will render.

Actual behavior:

test.tsx:6:1 - error TS2605: JSX element type 'string' is not a constructor function for JSX elements.

I have the horrible feeling that I'm doing something incredibly stupid, but I can't see what.

Playground Link:
Playground does not support tsx.

Other Information:
tsconfig.json:

{
    "compilerOptions": {
        "jsx": "react"
    }
}

package.json deps:

  "devDependencies": {
    "@types/react": "^16.8.5",
    "react": "^16.8.3",
    "typescript": "^3.4.0-dev.20190226"
  }

Related Issues:

The phrase "JSX element type is not a constructor function for JSX elements." is very common in searches, but none of them seemed related to this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions