Farhan Islam
Farhan Islam

Reputation: 15

React Native error! Element type is invalid: expected a string or a class/function but got: undefined

I am a junior in my advanced front web development class and we just started learn react. I am fairly new to React and struggling with this error. I am building an e-commerce website for my final project and I am using @moltin/sdk with React and Redux through create-react-app so I dont have the webpack config. My codes complied successfully, however, I am getting this error:

Blockquote 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, or you might have mixed up default and named imports.

I am not sure what is it wrong. I checked all my components and have export default for each of them in their own respective file since export default is limited to one per document. Any help would be greatly appreciated, I have included by index.js file which where the issues is coming from according to the error and the error message.

Error Message Picture

import React from 'react';
import {render} from 'react-dom';
import './index.css';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'react-router-redux';
import App from '../src/component/App.js';
import store, { history } from './store';

const target = document.getElementById('root');

render(
  <Provider store={store}>
  <ConnectedRouter history={history}>
    <div>
      <App />
    </div>
  </ConnectedRouter>
</Provider>, target
);

This is on React ^16.13.1, react-redux ^7.2.0, and redux ^4.0.5. Thank you again!

Upvotes: 1

Views: 87

Answers (1)

Allan Joseph
Allan Joseph

Reputation: 145

import { ConnectedRouter } from 'connected-react-router'

This is the actual import for Connected Router. connected-react-router is the library used for Redux binding for React Router. Install this package with the below command.

npm install --save connected-react-router

Upvotes: 1

Related Questions