I am trying to create a container which is subscribed to the store using mapStateToProps. I am able to change the state using reducers in this fashion
export default function firstReducer(state={}, action) {
switch(action.type){
case 'ADD_USERNAME':
return Object.assign({}, state, {
username: action.payload
});
default:
return state;
}
}
However, mapStateToProps is not getting called even once. Where am I going wrong
export default class myComponent extends React.Component{
render(){
return(
<h1>this.props.userName</h1>
)
}
}
function mapStateToProps(state){
console.log("Hey");
return{
userName: state.username
};
}
export const myContainer = connect(mapStateToProps, null)(myComponent);