-
Notifications
You must be signed in to change notification settings - Fork 26.1k
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
Compilation error - transform-react-jsx: pragma has been set but pragmaFrag has not been set #11230
Comments
I got the same issue when upgrade
I did use react fragment shorthand syntax in Everything works great with
|
I just ran into the same thing. It looks like there's a problem rendering shorthand fragments My temporary fix was to switch it all to |
The same issue when upgrade: |
Thanks for the workaround @kretzm, I've updated the main post to highlight your solution. Great to know it's related to Fragments, I hadn't figured that out! 💯 |
I have the same issue. To reproduce the problem you can checkout this repo that I created. https://github.com/itsmylife/nextjs-pragmafrag-error My workaround is this: Install yarn add -D @babel/plugin-transform-react-jsx Then, create a .babelrc file in the root of the project. {
"presets": ["next/babel"],
"plugins": [
[
"@babel/plugin-transform-react-jsx",
{
"pragmaFrag": "React.Fragment"
}
]
]
} And with those you can keep using shorthand React.Fragment. But I think we should not have to do those. Edit: |
I think this |
We're looking into this now (Babel team) Workaround #11230 (comment) as per setting |
FWIW this particular issue doesn't seem related to the "mess". |
I got the same issue while trying the static blog example. |
We need help debugging this issue: did you have a We have found a regression that is only triggered when |
Ok, we have identified the bug. We will release a fix soon. |
I ran into the same error after updating @babel/preset-react to 7.9.0 and below comment helped me fix this issue temporarily |
@nicolo-ribaudo I can confirm that I don't use |
Sorry for the trouble yall, that was a fun debug session with the team :P |
Gotta love when the bug is so fresh you can't even google for it! |
Sorry Nicolo that I couldn't reply in time but I am happy that you guys identified the bug. We are looking for the new release :) |
This should be fixed in |
It works! Thank you very much! |
I can confirm it works for us too! I'd love to know what actually happened, and how we could avoid this in the future. I thought yarn.lock file was supposed to protect against such things. |
Yes, it should. New projects don't have a lockfile yet so they got the broken version, but I'm not sure how existing projects could have stopped working. Btw, we'll look into adding an e2e test for Babel with next.js! |
Thanks for the help. It worked for me. |
Thanks for quick action. We are all appreciated. |
…t pragmaFrag has not been set` error (see vercel/next.js#11230)
* Trialing work around for `transform-react-jsx: pragma has been set but pragmaFrag has not been set` error (see vercel/next.js#11230) * use Fragment instead of React.Fragment Co-authored-by: Dominik Wilkowski <hi@dominik-wilkowski.com> Co-authored-by: maryam-mv <mv.mostajir@gmail.com>
@Vadorequest Solved my problem with ReactDOM.render(
<React.StrictMode>
<BrowserRouter>
<App />
</BrowserRouter>
</React.StrictMode>,
document.getElementById('root')
); in my component file i have these /** @jsx jsx */
/* @jsxFrag React.Fragment */
import * as React from "react";
import {useState} from 'react';
import { css, jsx } from '@emotion/core';
import {Link} from "react-router-dom"; i get the error react is defined but never used but it compiles fine with no errors. hope that helps |
Using Next 10.0.2 and Error:
Yarn why result:
Edit: related to #18461 |
Can you try with Babel 7.12? |
@nicolo-ribaudo I've managed to fix eventually by rollbacking to |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
My build on Zeit is erroring with the following stack trace:
I can't explain it, I haven't changed anything related to node modules. Here is the source code of
pages/_error.tsx
:To Reproduce
No idea, everything was working fine until then.
Since I didn't change anything on my side, it may be related to some node module, most potentially with
transform-react-jsx
babel plugin.I don't know what's causing the issue.
Expected behavior
Should compile.
Workarounds
Use React.Fragment
Using
<React.Fragment></React.Fragment>
instead of<></>
- See #11230 (comment)The text was updated successfully, but these errors were encountered: