Skip to content
Advertisement

Received a promise that resolves to: undefined. Promise elements must resolve to a class or function

I am trying to use lazy loading in react. I have imported lazy and Suspense components from react. The page doesn’t show anything again. but the error I got is:

Expected the result of a dynamic import() call. Instead received: [object Object]. Element type is invalid. Received a promise that resolves to: undefined. Promise elements must resolve to a class or function.

This is SibaCard Component

JavaScript

This is the component I am importing the Sibacard

JavaScript

Can someone tell me what I am doing wrong?

Advertisement

Answer

The docs state that:

React.lazy takes a function that must call a dynamic import(). This must return a Promise which resolves to a module with a default export containing a React component.

If you change your export of the SibaCard component from a named export to a default export it should work as expected.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement