Error: Component definition is missing display name
I'm receiving this error in Vercel, which exits the build in the Layout.tsx file on line 27:
const dynamicProps = {
loading: () => <Loading />
};
const SignUpView = dynamic(() => import('@components/auth/SignUpView'), dynamicProps);
const ForgotPassword = dynamic(() => import('@components/auth/ForgotPassword'), dynamicProps);
const FeatureBar = dynamic(() => import('@components/common/FeatureBar'), dynamicProps);
Error: Component definition is missing display name react/display-name
It seems to be a linting error, but I've exhausted my options.
I've got the latest version of this repo, which includes NextJS 11.0.0 and Typescript 4.3.4.
I have ignored this rule for now in .eslintrc, but it seems more like a hack:
{
"extends": "next",
"rules": {
"react/display-name": "off"
}
}
I can reproduce this bug with the following steps.
In Vercel, create a new project using Next.js Commerce template.
- 1st commit will work fine.
- make minor changes to any HTML text, commit as 2nd commit and deploy
- deployment will fail with a few ESLint
react/display-nameerror - try to manual redeploy 1st commit now and it still gets deployed fine
- revert 2nd commit (as the 3rd commit) and deploy, the deployment will fail with
react/display-nameerror again

If you don't want to modify your esilnt, you can add a display name to the components. Typically this happens when wrapping a component with something like React.memo()
export const MyComponent: React.FC = () => {
...
}
MyComponent.displayName = 'MyComponent'