user image

Joseph Morgan
Published in : 2022-01-31

[solved] Error: Element type is invalid: expected a string (for built-in components)

React js

Hello Everyone,
I am facing this error in my Reactjs App when I try to install react-snap updated the index.js this error came suddenly 

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

The used code in index.js is 

import 'react-app-polyfill/ie11';import 'react-app-polyfill/stable';import 'react-perfect-scrollbar/dist/css/styles.css';import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';import 'react-quill/dist/quill.snow.css';import 'prismjs/prism';import 'prismjs/components/prism-bash';import 'prismjs/components/prism-javascript';import 'prismjs/components/prism-jsx';import 'nprogress/nprogress.css';import 'src/__mocks__';import 'src/assets/css/prism.css';import 'src/mixins/chartjs';import React from 'react';import { hydrate, render } from "react-dom";// import ReactDOM from 'react-dom';import { Provider } from 'react-redux';import { enableES5 } from 'immer';import * as serviceWorker from 'src/serviceWorker';import store from 'src/store';import { SettingsProvider } from 'src/contexts/SettingsContext';import App from 'src/App';enableES5();const APP = ( <Provider store={store}> <SettingsProvider> <App /> </SettingsProvider></Provider>);const rootElement = document.getElementById("root");if (rootElement.hasChildNodes()) { hydrate(<APP />, rootElement);} else { render(<APP />, rootElement);}serviceWorker.register();

What should I do?


Mohamed Atef Date : 2022-01-31

Best answers


Best answers


There is a problem in using the const which called APP, you used it like component and exported from somewhere but the truth is it's regular constant so you just need to call it's name using APP not <APP />

const rootElement = document.getElementById("root");if (rootElement.hasChildNodes()) { hydrate(APP, rootElement);} else { render(APP, rootElement);}

Good luck

Joseph Morgan Date : 2022-01-31

Thank you so much :)
it's beginners mistakes

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

How to use Datepick of Mui with Formik
Publish date: 2022-02-14 | Comments: 7

Tag: React js

Warning: React.jsx: type is invalid
Publish date: 2022-05-06 | Comments: 1

Tag: React js

[solved] useEffect is repeating the request Reactjs
Publish date: 2022-04-07 | Comments: 2

Tag: React js

React Component displaying a list of lines
Publish date: 2022-03-19 | Comments: 3

Tag: React js

Unexpected mix of '&&' and '||' Reactjs
Publish date: 2021-10-30 | Comments: 0

Tag: React js

TypeError: Super expression must either be null or a function
Publish date: 2022-03-13 | Comments: 2

Tag: React js