Regression in preset-react 7.9.x.
See original GitHub issueBug Report
- I would like to work on a fix!
Current Behavior
After upgrade @babel/preset-react from 7.8.x to 7.9.x all tests in my project are failing with message:
Error: ProgressBar(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.
After bisecting babel I have found a commit which breaks my project. https://github.com/babel/babel/commit/748897be0772d3569c92c26e061ba05ac26563b4
Those lines https://github.com/babel/babel/pull/11154/files#diff-8c3c9c6362e23bd456da3fb129f49a57L10-R12 gave me a clue how to workaround it. So, I added
{pragma: "React.createElement"}
and it helped.
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
- Filename:
babel.config.js
Original
module.exports = function(api) {
const isTest = api.env('test');
const envOptions = isTest
? {
"targets": {
"node": "current"
}
}
: {
modules: false,
useBuiltIns: 'usage',
corejs: 3,
// debug: true,
};
return {
"presets": [
["@babel/preset-env", envOptions],
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-class-properties"
],
};
};
- Filename:
babel.config.js
With workaround
module.exports = function(api) {
const isTest = api.env('test');
const envOptions = isTest
? {
"targets": {
"node": "current"
}
}
: {
modules: false,
useBuiltIns: 'usage',
corejs: 3,
// debug: true,
};
return {
"presets": [
["@babel/preset-env", envOptions],
["@babel/preset-react", {
pragma: "React.createElement",
}],
],
"plugins": [
"@babel/plugin-proposal-class-properties"
],
};
};
Environment
System:
OS: Linux 5.4 Debian GNU/Linux bullseye/sid
Binaries:
Node: 12.16.1 - ~/apps/nodejs/bin/node
Yarn: 1.22.4 - /usr/bin/yarn
npm: 6.13.4 - ~/apps/nodejs/bin/npm
npmPackages:
@babel/core: ^7.1.0 => 7.9.0
@babel/plugin-proposal-class-properties: ^7.0.0 => 7.8.3
@babel/preset-env: ^7.0.0 => 7.9.0
@babel/preset-react: ^7.0.0 => 7.9.1
babel-core: ^7.0.0-bridge.0 => 7.0.0-bridge.0
babel-eslint: ^10.0.0 => 10.1.0
babel-jest: ^25.1 => 25.1.0
babel-loader: ^8.0.0 => 8.1.0
eslint: ^6 => 6.8.0
jest: ^25.1 => 25.1.0
webpack: ^4.0.0 => 4.42.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:14 (6 by maintainers)
Top Results From Across the Web
@babel/preset-react - npm
Babel preset for all React plugins.. Latest version: 7.18.6, last published: 6 months ago. Start using @babel/preset-react in your project ...
Read more >@babel/preset-react | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >Changelog - Cypress Documentation
Fixes a regression introduced in Cypress 10.0 where Cypress no longer persisted the spec filter in the 'Search Specs' field during a session...
Read more >Firebase JavaScript SDK Release Notes - Google
0 - February 20, 2020. Caution: This build introduced a regression where Node and CJS bundles for Cloud Firestore do not work. Please...
Read more >Evidence for Frequent Regression of Cervical Intraepithelial ...
A positive test does not identify which HR HPV genotype(s) are present. Hybrid Capture 2 is also well-known to cross-react with untargeted HPV...
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
@nicolo-ribaudo Disregard, sorry! Seems like CI was pulling in the old version for some reason. I updated all my packages, rebuilt my
yarn.lock
file, and everything is working now.Yes sorry, this was a bug in
@babel/generaror
.https://www.npmjs.com/package/@babel/generator