menu
announcement

Spectrum is now read-only. Learn more about the decision in our official announcement.

Redux

A community of developers who use Redux. This community is a great place to ask questions and talk all about Redux.

Channels
Team

MapstateToProps not Re-rendering?

October 12, 2019 at 5:56am

MapstateToProps not Re-rendering?

October 12, 2019 at 5:56am
Well, there might be a bug or something but I just got into this problem where redux mapstatetoprops won't rerender the component. and The solution is pretty wired. I know that map state will combine the current state with the old and if change found then rerender the component but that is not the case with arrays. So for example
The Below will not realtime rerender the component as the response of Cart will be an Array
const mapStateToProps = (state /*, ownProps*/) => {
return {
Cart : state.Cart.cart
}
}
But if we use an Object
const mapStateToProps = (state /*, ownProps*/) => {
return {
Cart : state.Cart
}
}
The Above one will run. Why is this a bug or something?
No messages yet