@emotion/core doesn't handle React.Fragment shorthand correctly.
See original GitHub issueCurrent behavior: Throws an error “React is not defined”. If React is imported then throws a warning “‘React’ is defined but never used.”
To reproduce:
- Create an app with
create-react-app
- Create a component which uses
jsx
instead ofReact
. - Use
React.Fragment
shorthand as the container of that component. - Import the component and render it.
CodeSandbox: https://codesandbox.io/s/pensive-edison-bdkpp
Expected behavior:
It would be great if emotion
could handle the shorthand out of the box. If not, it should not at least warn me about React not being used.
Environment information:
react
version: 16.10.2@emotion/core
version: 10.0.21
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
React fragment shorthand failing to compile - Stack Overflow
The project in question is using React-16.2.0 which has the capability to use Fragments and the Fragment shorthand.
Read more >MEDICAL ABBREVIATIONS - CHFS.ky.gov
At present, the only approved medical abbreviations that are acceptable for LHD documentation are in this section, the Immunization Section, and Marilyn Fuller ......
Read more >Fragments - React
Fragments let you group a list of children without adding extra nodes to the DOM. There is also a new short syntax for...
Read more >Untitled
React Bootstrap overflow utility helps to quickly configure how content overflows ... Do not use it on production sites facing the Web: it...
Read more >The css Prop - Emotion
automatic) should be used and you are already using a React version that has the new JSX runtimes (hence runtime: 'automatic' being configured...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@shakib609 @Andarist - I think that the issue tracking this problem is https://github.com/yannickcr/eslint-plugin-react/issues/2156. I added this comment to the end of that issue.
P.S. - Anyone ending up here from Google, the workaround is simple: use
<React.Fragment>
instead of the shorthand<>
syntax.It can’t - because it’s handled by Babel and not by Emotion.
You get runtime
Uncaught ReferenceError: React is not defined
. Emotion can’t handle this because it’s not capable of doing static analysis. This is a job for ESLint.