The below object is action.data
has a nested object address
{
name: \'Ben\',
address: {
country: \'Australia\',
From Redux:
Common Redux misconception: you need to deeply clone the state. Reality: if something inside doesn't change, keep its reference the same!
No, shallow copy of Unchanged properties.
Changed properties will be anyway new values, so no question of type of copy.
In code we achieve it like this return {...prevState}
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.