question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@emotion/core doesn't handle React.Fragment shorthand correctly.

See original GitHub issue

Current behavior: Throws an error “React is not defined”. If React is imported then throws a warning “‘React’ is defined but never used.”

To reproduce:

  1. Create an app with create-react-app
  2. Create a component which uses jsx instead of React.
  3. Use React.Fragment shorthand as the container of that component.
  4. 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:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
justingrantcommented, Nov 18, 2019

@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.

2reactions
Andaristcommented, Oct 15, 2019

It would be great if emotion could handle the shorthand out of the box.

It can’t - because it’s handled by Babel and not by Emotion.

If not, it should not at least warn me about React not being used.

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found