Minified React error #152 - comments before JSX
See original GitHub issueSince CRA 3.4.1 Probably a babel issue
The following code raise an error on built version :
import React from 'react';
const Component = props => {
return ( // a comment
<div>
toto
</div>
);
};
export default Component;
After building the app, i get the following error :
react-dom.production.min.js:209 Error: Minified React error #152; visit https://reactjs.org/docs/error-decoder.html?invariant=152&args[]=Component for the full message or use the non-minified dev environment for full errors and additional helpful warnings. at react-dom.production.min.js:149 at za (react-dom.production.min.js:173) at vo (react-dom.production.min.js:262) at cu (react-dom.production.min.js:246) at ou (react-dom.production.min.js:246) at Zo (react-dom.production.min.js:239) at qo (react-dom.production.min.js:230) at Du (react-dom.production.min.js:281) at react-dom.production.min.js:284 at tu (react-dom.production.min.js:240)
Removing the comment fixes the error
Issue Analytics
- State:
- Created 4 years ago
- Reactions:144
- Comments:57 (1 by maintainers)
I used this regex in VSCode to find the troublesome comments:
\(\s*\n?\s*//
I was able to resolve mine by removing the comments as well. Not sure of a fix yet.