Answer the question
In order to leave comments, you need to log in
Not passed to react class, store (redux)?
Not passed to the Cour class (react class) store (Redux).
The console displays just undefined, it doesn't even enter the mapStateToProps function.
What could be the problem? Doesn't throw any errors.
var Cour = React.createClass({
render: function () {
console.log(this.props.user)
return (
<div>
<h1>Я мудак</h1>
</div>)
}
});
const initialState = {
user: 'Unknown User'
};
function userstate(state = initialState) {
return state;
}
var store = Redux.createStore(userstate)
function mapStateToProps (state) {
console.log('wtf')
return {
user: state.user
}
}
ReactRedux.connect(mapStateToProps)(Cour);
ReactDOM.render(
<ReactRedux.Provider store={store}>
<Cour />
</ReactRedux.Provider>,
document.getElementById("content")
);
Answer the question
In order to leave comments, you need to log in
var ConnectedCour = ReactRedux.connect(mapStateToProps)(Cour)
<ReactRedux.Provider store={store}>
<ConnectedCour />
</ReactRedux.Provider>
mapDispatchToProps
forgotten: connect(mapStateToProps, mapDispatchToProps)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question