Upgraded React - Lazy "ctor is not a function"

Viewed 1651

I just upgraded React to 17 and I'm getting a weird error.

TypeError: ctor is not a function

enter image description here

My Lazy components get loaded like this

const Course = lazy(() => import('./containers/course'))
const Learner = lazy(() => import('./containers/learners'))
const Report = lazy(() => import('./containers/reports'))
const Home = lazy(() => import('./containers/home'))

Is this the problem!?

I've deleted node_modules etc so many times.

3 Answers

You'll have update react-dom to the same version, in my case had to update both react 17.0.2 and react-dom 17.0.0

Fixed with upgrade of React-router

This is an irrelevant to this question but for Next.js users, use next@12.2.0 & react@18 to avoid this error. I used next@12.1.6 and had the same issue but after upgrading next version to 12.2.0, the problem has magically solved!

Related