Skip to content
Advertisement

Error React createElement type is invalid expected a string for built-in components or a class function for composite components but got object

I am trying to change my client side rendered react app to be rendered on server side. I am using React with TypeScript. Here is the error:

JavaScript

Here is my package.json dependencies:

JavaScript

And here is my rendered.js class where the error seems to be triggered:

JavaScript

And here is my index.tsx file:

JavaScript

I’ve tried changing the imports of App.tsx although it didn’t work for me. Thanks in advance for your help!

Advertisement

Answer

Try to change the line in your rendered.js file

from

JavaScript

to

JavaScript

I think that’s because you use babel register or other transformer, transform default export into { default: [function App] }, so that the React.createElement function place the object but not the Component function into type field

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