Typescript: JSX element type 'string' is not a constructor function for JSX elements.

Created on 26 Feb 2019  路  2Comments  路  Source: microsoft/TypeScript


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.

Duplicate

Most helpful comment

Many thanks. At least there's another way to search for that issue now.

All 2 comments

Many thanks. At least there's another way to search for that issue now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Roam-Cooper picture Roam-Cooper  路  3Comments

blendsdk picture blendsdk  路  3Comments

uber5001 picture uber5001  路  3Comments

dlaberge picture dlaberge  路  3Comments

jbondc picture jbondc  路  3Comments