Getting "React.createElement: type is invalid" error with 8.28.5
See original GitHub issueDependabot bumped react-intersection-observer
in one of my repos to version 8.28.5 and since then, every time I use the <InView triggerOnce>
component, I’m getting a following error:
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
Check your code at xxx.js:100.
in xxx
in Context.Provider
in ConnectFunction
in ConnectFunction (at _app.js:36)
in App
in Context.Provider
in Provider
in withRedux(App)
in Unknown
in Context.Provider
in Context.Provider
in Context.Provider
in Context.Provider
in AppContainer
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
at ReactDOMServerRenderer.render (/xxx/node_modules/react-dom/cjs/react-dom-server.node.development.js:3743:17)
at ReactDOMServerRenderer.read (/xxx/node_modules/react-dom/cjs/react-dom-server.node.development.js:3373:29)
at renderToString (/xxx/node_modules/react-dom/cjs/react-dom-server.node.development.js:3988:27)
at Object.renderPage (/xxx/node_modules/next/dist/next-server/server/render.js:48:686)
at Function.getInitialProps (webpack-internal:///./node_modules/next/dist/pages/_document.js:129:19)
at Function.getInitialProps (webpack-internal:///./pages/_document.js:20:85)
at loadGetInitialProps (/xxx/node_modules/next/dist/next-server/lib/utils.js:5:101)
at renderToHTML (/xxx/node_modules/next/dist/next-server/server/render.js:48:977)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Has anything changed recently with regards to <InView triggerOnce>
?
Reverting back to 8.27.1 (which was the version previously used in my repo) fixes the problem.
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
React.createElement: type is invalid -- expected a string
Error : Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
Read more >Warning: React.createElement: type is invalid -- expected a ...
I have uninstalled and reinstalled reac and react-dom, and the problem still persists, try a new project cloning it from a friend, and...
Read more >React.createElement: type is invalid — expected a string
The error is happening when you are creating a new element – in this case initiantiating your custom component using createElement. The actual ......
Read more >Error React createElement type is invalid expected a string for ...
I get the following error. React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for ...
Read more >JSX In Depth - React
Specifying The React Element Type ... The first part of a JSX tag determines the type of the React element. Capitalized types indicate...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve found the culprit: I had
InView
imported as a default export, not a named one. I changed:import InView from 'react-intersection-observer';
toimport { InView } from 'react-intersection-observer';
and it worked. Weird because it worked @ 8.27.1.Can you clarify/make an example?
The package exports all of these, so not sure what problem you might be seeing: