Closed shabanraza closed 7 years ago
This is a usage question, and should be asked on Stack Overflow instead.
99.9% of the time, this is because you are accidentally mutating data, usually in your reducer. See http://redux.js.org/docs/faq/ReactRedux.html#react-not-rerendering for links to more information on the topic.
@markerikson advice "99.9% of the time, this is because you are accidentally mutating data" was spot on. For me it was because I was making a shallow copy of a nested object & the nested values were still being passed by reference.
I made a deep clone by:
const deepCloneOfNestedObject = JSON.parse(JSON.stringify(nestedObject))
@shenders13 : fwiw, deep cloning is also not a good idea, as you'll be making unnecessary new references, and possibly causing too many re-renders instead. Please see http://redux.js.org/docs/faq/ReactRedux.html#react-rendering-too-often, http://redux.js.org/docs/faq/Performance.html#performance-clone-state, and http://redux.js.org/docs/recipes/reducers/ImmutableUpdatePatterns.html for more info on how to properly update state.
After dispatching an event are you retuning a new state or just modifying existing state ?
@markerikson answer solved my problem, if you're trying to apply this concept to an array on your app state this can be a little bit trickier, make sure you're creating a new array first and then concatenating the previous data onto the new array if you're trying to add to an existing array on your app state.
Its is my parent component i have dispatch the action from child component and state changes but render function of parent component does not called .
In child component every time when i click on checkbox then i dispatch the action for updating the state in reducer and i received new state in mapStatetoprop but it does not update the UI
Below the code of child component where i dispatch the action
here i dispatching the action on every checkbox (handleChange() function ) see below
Please help me guys i am stuck on this code