New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Container and components not re-rendering upon successful action dispatch #1159
Comments
@davidhtien, you will need to expose state to your component via // ...current code here
// Which part of the Redux global state does our component want to receive as props?
function mapStateToProps(state) {
return {
date: state.date
}
}
// Which action creators does it want to receive by props?
function mapDispatchToProps(dispatch) {
return {
handlePrev: (date) => dispatch(prevWeek(date)),
handleNext: (date) => dispatch(nextWeek(date)),
}
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(WeekBar) Now, both your state and action creators are available via |
Please provide full code as a GitHub project. Also this does not (so far) appear an issue with Redux itself. For this reason please ask on StackOverfow first. If nobody helps you there, we are happy to take a look, but it's best to avoid creating issues for "something doesn't work" questions unless you're sure you are using the library correctly. |
Thank you guys for your quick responses! Sorry about spamming the issues section, wasn't quite thinking straight yesterday after a long day, totally slipped my mind to post on SO first. Thanks for helping out a noob |
No problem. Feel free to post a link to SO question here since we have this issue anyway ;-) |
@roblafeve I tried to add your code but I doesn't seem to work? I put it at the end of my component code and at the end of my container code Thank you guys again for your help! |
I think the problem has to do with state mutation. |
I've looked at
#585
reduxjs/react-redux#12
but can't seem to make my code work.
By console.log and redux devtools I can see that my state is successfully updated but there is no fresh render
the reducer
the container code
the component code
The text was updated successfully, but these errors were encountered: