I tracked down the bug to a return statement that the minifier resolved to return null/nothing, but the dev server returned a component as expected.
CRA not ejected
react-scripts 3.4.1
bug seen in Firefox, Safari and Chrome on Mac and PC
class arrow function:
renderOption = (option)=>{
const { wi } = this.props
let sourceWi = wi
return (
// myVar1,
// myVar2,
// myVar3
<MyComponent
title={ sourceWi.title }
revIndex={ option.revIndex }
sourceWi={ sourceWi }
/>
)
}
After npm run build, this code no longer returns a component.
Arrow function should return MyComponent (which works fine using dev server)
After running npm run build, it appears the minifier returns nothing. Even though the return statement wraps its content in parentheses (). Perhaps it is confused by the commented variables //
I corrected the bug by creating a variable and then returning it:
renderOption = (option)=>{
const { wi } = this.props
let sourceWi = wi
const res = (
// myVar1,
// myVar2,
// myVar3
<MyComponent
title={ sourceWi.title }
revIndex={ option.revIndex }
sourceWi={ sourceWi }
/>
)
return res // NOTE returning the const res instead of the parentheses builds and runs fine
}
To reproduce the behaviour of the bug I simply return nothing instead of res. This is why I think it is a minification problem that ignores the contents inside the parentheses.
See also #8687
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.
I dont think this is resolved, see other issues
Update: see my comment here https://github.com/facebook/create-react-app/issues/8687#issuecomment-646764708
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.
I see a lot of people saying:
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.
This issue is still open and it's due to webpack / babel
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.
This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.
Most helpful comment
See also #8687