Skip to content Skip to sidebar Skip to footer

Reactjs Redux:mapstatetoprops Not Rendering The Component On State Change

I have search filter and sort inputs on the same component.I'm using reselect(selector package) where the data array is filtered and sorted. The mapStateToProps is updating the com

Solution 1:

MapStateToProps does a shallow compare of the values returned each time. A shallow compare will compare references for objects and arrays. When you sort, the array is sorted in place, so the reference doesn't change. See sort. You could prove it by returning a new reference to the array:

 return [...ListOfCategory.sort(a,b) // rest of sort code ]

Post a Comment for "Reactjs Redux:mapstatetoprops Not Rendering The Component On State Change"