“Element type is invalid” error when placing MUI Typography in Next.js

2024-01-27

Error

In Next.js, when placing the MUI element Typography under certain conditions, the following error occurs:

Error: Element type is invalid. Received a promise that resolves to: undefined. Lazy element type must resolve to a class or function...

Environment

Next.js: 14.0.4

Solution

This is likely a bug in a specific version.
Downgrading the version can resolve the issue.

It works without problems on Next.js 14.0.3.
Modify the Next.js version in package.json to 14.0.3, and run npm install.

Reference

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) in react native project