Reputation: 4014
I have the following code:
import React from 'react';
import ReactDOM from 'react-dom';
import rootReducer from './redux/reducers/rootReducer';
import {Provider} from 'react-redux';
import {createStore, applyMiddleware} from 'redux';
import {BrowserRouter} from 'react-router-dom';
import thunk from 'redux-thunk';
import Main from './Main';
import './i18n';
const store = createStore(rootReducer,
{},
applyMiddleware(thunk));
ReactDOM.render(<Provider store={store}><BrowserRouter><Main/></BrowserRouter></Provider>, document.getElementById('app'));
But when I try to run it I get:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
Check the render method of
Provider
.
My Main
class looks like this:
function mapStateToProps(state) {
return {
dashboard: state.dashboard
}
}
function mapDispatchToProps(dispatch) {
return bindActionCreators(actions, dispatch)
}
const Main = withRouter(connect(mapStateToProps, mapDispatchToProps)(App));
export default Main;
What is the problem?
Upvotes: 2
Views: 454
Reputation: 4014
I was using [email protected]
. From the docs:
https://github.com/reduxjs/react-redux/releases/tag/v6.0.0
Passing store as a prop to a connected component is no longer supported. Instead, you may pass a custom context={MyContext} prop to both and . You may also pass {context : MyContext} as an option to connect.
Anyways, downgrading to 5.1
solved it.
Upvotes: 1