Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React 16.2 <Fragment> gives Uncaught error: Element type is invalid

I just updated to react 16.2 and I want to use the cool Fragment feature. However I get strange error as soon as just use it in a simple way:

<React.Fragment>asd</React.Fragment>

The error states: Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: symbol.

When I log the above code and just a random component I have defined I get this information:

$$typeof: Symbol(react.element)
key: null
props: {children: "asd"}
ref: null
type: Symbol(react.fragment)
...

When I log my element I get the almost same information:

$$typeof: Symbol(react.element)
key: null
props: {children: "sfdghs"}
ref: null
type:ƒ Column(_ref)

My question is: why does the app expect string or function.

All related dependancies from my package.json are as such:

  • "devDependencies": {... "@types/react": "^16.0.0" ...}
  • "dependencies" : {... "react": "^16.2.0", "typescript": "2.6.2" ...}

If anyone can give me any information on how to debug this, I will be very grateful!

like image 410
Chris Panayotova Avatar asked Dec 08 '17 12:12

Chris Panayotova


1 Answers

You need a minimum of 16.2.0 for both react & react-dom.

like image 158
Chariyski Avatar answered Sep 28 '22 04:09

Chariyski