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
Can't use React.Fragment #12097
Comments
@ha404 Check your node_modules and make sure you have react 16.2 |
Maybe you have an older |
Both are at |
Can you reproduce this in a fiddle? If not there might be some kind of local cache on your system that’s messing this up. Please provide a reproducing project. |
@gaearon https://codesandbox.io/s/0pvzqryz2l. It just seems to not like this fragments syntax. |
As mentioned in the blog post, the syntax support is not expected to come to all tools soon. That seems irrelevant to the problem you were describing in the initial post though. |
Understandable, I just can't understand why I'm getting similar errors. Is there anything else I need other than |
@ha404 No, that one is IE11-specific.
No. How did you verify that you have them? Can you post the content of |
@gaearon that was the second thing I tried looking at haha, here ya go:
|
OK, my best guess is you accidentally have two React's in the bundle, one being an older version. Try running I don't think we can help further here—if it doesn't reproduce on a new project, it's definitely an issue with how your project is set up. You either have two Reacts or have some aggressive caching turned on and accidentally work with an older version. |
Maybe a nice |
@andrastothtw I found out an older version of React was being included externally and aliased in webpack D: |
For people who still have the problem even though you did not find an older version, try removing the |
@mikael1000 the message is clear I think
Use |
What do you mean by this?
|
Of course I made a stupid error. This is for bug reports and maybe I should know more about React before making bug reports. I should have asked for help somewhere instead. I cleared out my comments so people don't think about what I wrote. Sorry for taking unnecessary time and space. And thank you @TrySound for the answers. |
I think we should deprecated React.Fragment maybe, since it might be slow (by smart detecting parent and child and render the proper tags). btw, it doesn't support eg.
would rendered as
|
Hi mikael1000 (or @TrySound), would you be able to tell us what was the issue? We are having the exact same problem with React 16.7.0 |
@aximili Make sure you have the right version in your node_modules. It could be resolved incorrect. Also make sure your dependencies does not have different react version. React and react-dom packages usually should be in peer dependencies of libraries. Another way to solve the problem is force react version with yarn resolutions. |
Thx so much @TrySound It is only affecting this particular React project with TypeScript, we must be missing something. How do you check for the dependencies issue that you mentioned? This is what's in our package.json |
I'm looking at node_modules folder and check all react dependencies |
Do you want to request a feature or report a bug?
bug
What is the current behavior?
broken in runtime
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
<React.Fragment></React.Fragment>
or<></>
syntax to render mapped fragments.What is the expected behavior?
I expect the component to render. It works fine when rendering as an array (I just don't want to type a comma between my elements). It also works fine if I use a
<div>
but that's not semantically correct.Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
The text was updated successfully, but these errors were encountered: