Don’t get surprised by the list of answers for a single question. There are various causes for this issue;
For my case, the warning was
warning.js:33 Warning: React.createElement: type is invalid — expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it’s defined in. Check your code at index.js:13.
Followed by the error
invariant.js:42 Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it’s defined in.
I couldn’t understand the error since it doesn’t mention any method or file name. I was able to resolve only after looking at this warning, mentioned above.
I have the following line at the index.js.
When I googled for the above error with the keyword “ConnectedRouter” I found the solution in a GitHub page.
The error is because, when we install
react-router-redux package, by default we install this one.
https://github.com/reactjs/react-router-redux but not the actual library.
To resolve this error, install the proper package by specifing the npm scope with
npm install [email protected]
You don’t need to remove the wrongly installed package. It will be automatically overwritten.
PS: Even warning helps you. Don’t neglect warning just looking at the error alone.