mirror of
https://github.com/facebook/react.git
synced 2026-02-26 18:58:05 +00:00
Fix object spread operator (#8378)
Object spread operator performs shallow copy of object's arguments, so it should be placed before new properties are assigned.
This commit is contained in:
committed by
Dan Abramov
parent
e64510ab21
commit
e958cdbd36
@@ -226,7 +226,7 @@ var newPlayer = Object.assign({}, player, {score: 2});
|
||||
// Now player is unchanged, but newPlayer is {score: 2, name: 'Jeff'}
|
||||
|
||||
// Or if you are using object spread, you can write:
|
||||
// var newPlayer = {score: 2, ...player};
|
||||
// var newPlayer = {...player, score: 2};
|
||||
```
|
||||
|
||||
The end result is the same but by not mutating (or changing the underlying data) directly we now have an added benefit that can help us increase component and overall application performance.
|
||||
|
||||
Reference in New Issue
Block a user