Skip to main content

Comments inside a render return statement causes error

This error is difficult to trace.

While the React app running in the development environment shows no error, a build variant generated for example via

yarn build

displays an error like this

React app error

which in this instance was caused by the following comment lines inside the rendering return() statement of a functional React component.

    return (
// Ant Design Layout with resizable panel
<Flex gap="middle" wrap="wrap">
<BaseLayout>
<MainHeader>

So once corrected to the following

    return (
<Flex gap="middle" wrap="wrap">
<BaseLayout>
<MainHeader>

the build variant app runs correctly.

See this Stackoverflow reference, stackoverflow-minified-react-error-152-how-to-resolve-this.