React: "React.createElement: type is invalid" warning in IE11 when using React.Fragment

Created on 4 Dec 2017  路  12Comments  路  Source: facebook/react

https://codesandbox.io/embed/j30o67kpxy
React shows warning in console if I use React.Fragment

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
starter Bug good first issue (taken)

Most helpful comment

We'll likely cut a release in a week or so.

All 12 comments

Yeah, this is a false positive warning. It only appears if you use a Symbol polyfill.

I think it happens because we validate types here:

https://github.com/facebook/react/blob/8ce53671eddc8e96a51d87c9b1ad8cd0532ff9d5/packages/react/src/ReactElementValidator.js#L273-L277

React.Fragment is a symbol. However, if Symbol is polyfilled, then its typeof won't be 'symbol'鈥攊t will be just 'object'. So this condition won't be true.

To get around this, I think we should compare type directly to React.Fragment before concluding it's invalid.

I would like to work on it, if it is possible :)

Sure, it's yours.

@AyWa We didn't get a PR, so the submitter has fixed the issue.

@gaearon Yeah I saw yesterday that the PR was already made. Sadly I planed to work on it this week.
Anyway I hope I can find a good first issue soon ;)

Glad this is fixed. Any way this can make it into a release soon?

We'll likely cut a release in a week or so.

In the meantime if this is blocking you, you can yarn build -- dom from master and grab the builds from build/dist.

@dereklieu You can use https://www.npmjs.com/package/@xavescor/react package while new version is not released.

@gaearon Any update on when we are expecting this fix to land on npm?

@danwad C'mon build own react package until 16.3 release. It's several lines in your webpack config.

We plan a release within a week or so.

Was this page helpful?
0 / 5 - 0 ratings