I am new to redux and am writing a simple voting front end which allows the user to vote on their favourite framework (Angular, React, Vue). When a user clicks on a framewor
The reason you are not able to the the updated state immediately is because the operation of updating the store is async and writing
votedAngular(){
this.props.dispatch(voteAction('angular'));
console.log(this.props.votes.angular);
}
means that you are trying to check for the value as soon as the action is triggered. If you want to test the value, I would suggest you do it in the componentWillReceiveProps
function
componentWillReceiveProps(nextProps) {
console.log(nextProps.votes.angular);
}
However, for such operations where you need to test for redux values, redux-devtools-extension
is an ideal tool.