-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Description
I am connecting a component to the redux store, but only the react-router props are passed. Not even setting a testVar in the mapStateToProps function works.
Code simplified:
//index.js
import { createStore, applyMiddleware } from 'redux'
import thunk from 'redux-thunk'
import {initialState} from './reducers/RootReducer';
const store = createStore(RootReducer,initialState, applyMiddleware(thunk));
ReactDOM.render((
<Provider store={store}>
<BrowserRouter>
<App />
</BrowserRouter>
</Provider>
), document.getElementById('root'));
// App.js
import Home from './path/to/Home-component'
import About from './path/to/About-component'
...
<div>
<Switch>
<Route exact path='/' component={Home}/>
<Route path='/uploadsideletters' component={About}/>
...
</Switch>
</div>
...
// About.js
...
const mapStateToProps = (state) => ({
testVar: "test"
});
const mapDispatchToProps = (dispatch) => ({
// empty for now
});
export default connect(mapStateToProps,mapDispatchToProps)(About);When printing this.props in the render method to the console I get:
Object {history: Object, location: Object, params: Object, route: Object, routeParams: Object…}
My testVar is not there. Why is this?
Metadata
Metadata
Assignees
Labels
No labels