Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using <React.Fragment> prints warning with enzyme's mount with IE11 #1503

Closed
2 of 10 tasks
sylvain-hamel opened this issue Feb 1, 2018 · 6 comments
Closed
2 of 10 tasks

Comments

@sylvain-hamel
Copy link

sylvain-hamel commented Feb 1, 2018

I have a component that returns a <React.Fragment> object. When I mount the component using enzyme, in Internet Explorer 11, then React prints out this warning:

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

Followed by this warning:

Warning: Each child in an array or iterator should have a unique "key" prop. See https://fb.me/react-warning-keys for more information

About the 2nd warning, I'm pretty sure it's confusing the Fragment "array" with a common JSX array and it's trying to validate that each of the Fragment "element" has a key.

More info:

  • The same test runs without any warning on Chrome, Edge and Firefox.
  • This does not happen when I load the application on screen in Internet Explorer 11. It only happens in my unit tests; this is why I think it's related to enzyme.

Current behavior

Some warnings are printed

Expected behavior

No warnings should be printed

Your environment

Windows, Internet Explorer, Karma, Jasmine

API

  • shallow
  • mount
  • render

Version

library version
Enzyme 3.2.0
React 16.2.0

Adapter

  • enzyme-adapter-react-16
  • enzyme-adapter-react-15
  • enzyme-adapter-react-15.4
  • enzyme-adapter-react-14
  • enzyme-adapter-react-13
  • enzyme-adapter-react-helper
  • others ( )
@ljharb
Copy link
Member

ljharb commented Feb 2, 2018

See #1213; fragments aren't properly supported yet.

@ljharb ljharb closed this as completed Feb 2, 2018
@sylvain-hamel
Copy link
Author

I knew about that issue, but because my problem only occurs on IE11 I thought it could be a different thing. I'll wait for #1213 then. Thanks.

@sanshuiwang
Copy link

This problem appears in the development environment, the production environment did not.
so we can to ignore, do not worry.

@ljharb
Copy link
Member

ljharb commented Feb 26, 2018

@sanshuiwang since enzyme is a testing framework, and tests are only run in a development environment, it's definitely not something that can be ignored.

@ljharb ljharb reopened this Jul 17, 2018
@ljharb ljharb mentioned this issue Aug 8, 2018
41 tasks
@ljharb
Copy link
Member

ljharb commented Aug 18, 2018

@sylvain-hamel can you still reproduce this with latest enzyme? if not, please close; if so, can you provide the component code that's erroring?

@ljharb
Copy link
Member

ljharb commented Sep 5, 2018

I'm going to close this, pending repro info.

@ljharb ljharb closed this as completed Sep 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants