In Redux, is it necessary to do deep copy

From Redux:

Common Redux misconception: you need to deeply clone the state. Reality: if something inside doesn't change, keep its reference the same!


The "correct" way to handle updates of nested data is with multiple shallow copies, one for each level of nesting. It's also certainly okay to create a new object that just replaces one field completely, per your first example.

See the Redux docs section on Immutable Update Patterns for some info on how to properly do immutable updates, and also the Redux FAQ entry regarding deep cloning.

Tags:

Reactjs

Redux