[Question] Using jsx pragma, is there a way to use the <></> Fragment shorthand?
See original GitHub issueemotion
version: v10react
version: 16.7.0 / latest
Relevant code:
/** @jsx jsx */
import { jsx, css } from '@emotion/core';
export default function App() {
return (
<>
<div css={css`color: red;`}>Test</div>
<div>Fragment</div>
</>
);
}
What you did:
Attempted to use the Fragment shorthand enabled in Babel 7 <></>
, caused an error using the jsx pragma.
What happened:
Error thrown: React is undefined
Reproduction:
https://codesandbox.io/s/p7r4l19p2m
Problem description:
N/A
Suggested solution:
Additional documentation on the docs site if it is possible, or document that the fragment shorthand is unsupported.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Flow errors on <React.Fragment> or <></>, but not <Fragment>
I would like to use the <></> Fragment shorthand syntax, and this issue is stopping me from doing that for now. When I...
Read more >Emotion JSX Pragma and Fragment Shorthand Bug?
CodeSandbox is an online editor tailored for web applications.
Read more >Fragments - React
A common pattern in React is for a component to return multiple elements. Fragments let you group a list of children without adding...
Read more ><> or <React.Fragment> ? : r/reactjs - Reddit
You can transpile JSX to something other than React quite easily. Just set the pragma in this Babel plugin and it will use...
Read more >Readme — cljsx 1.0.0 - cljdoc
There are other macros with pragmas bound to other JSX compatible frameworks. inferno> bound to inferno-create-element/createElement and inferno/Fragment .
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
Fragments have different pragma - https://babeljs.io/docs/en/next/babel-plugin-transform-react-jsx.html#custom-1 . As it’s not of our interest, you should just rely on default one with React - therefore you should add:
to your file when using Fragment shorthand.
This hardly seems like a solution. Are we just to live with a hacky way of wanting to use both CSS prop and a React Fragment shorthand in the same file?