-
-
Notifications
You must be signed in to change notification settings - Fork 27k
production build, JSX code missing when returned in parentheses with leading comment #9066
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
Comments
I think maybe this is a result of React expecting there to be only one top level element returned by a render (and rightly or wrongly perceiving the comment as an element). If that is the case the same code should run fine if wrapped in a Is this the case? |
I think this is a duplicate of #8687 |
Update: see comment here #8687 (comment) |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
Describe the bug
In production builds, with
react-scripts build
, any JSX code inside an implicit return with parentheses()
, returnsundefined
when theres a leading comment before the JSXExample A
Example B
This issue only occurs within functions that return JSX. Variables work as expected. The development build is fine, this only occurs in production.
Without diving deeper I figure this issues lies in a dependency of react-scripts ..babel? ..or some compiler which now seems to treat the whole return body as a comment under these conditions.
This seems to be only occurring in a newer version of Create React App, we don't have this issue in a project running a year old CRA setup.
Did you try recovering your dependencies?
Environment
Steps to reproduce
With the code from above in a production build.
react-scripts build
Expected behavior
compiling some fantastic components
Actual behavior
compiling components that return undefined
Console errors will vary depending on the runtime access of the component. This was first noticed as a black page (no output) along with a cryptic message indicating "Nothing was returned from render" https://reactjs.org/docs/error-decoder.html/?invariant=152&args[]=a
Reproducible demo
n/a
The text was updated successfully, but these errors were encountered: