Using React.lazy gives Element type is invalid

Viewed 1832

So I have isolated the issue to this import:

const SelectRecipients = React.lazy(() => 
    import('../components/SelectRecipients'))

I get the following error:

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

I thought maybe it was an issue with the component itself and tried making a test component as follows:

import React from 'react'
export default () => {
return(<div>Hi</div)}

and then imported it instead of SelectRecipients and still got the error

CodeSandbox

1 Answers

For me, issue was having another index.js in the path, and my new component's codes was in index.jsx. This is because the index.js has higher priority when resolving imports.

Related