Skip to content

Commit d58e9d0

Browse files
authored
Update object spread syntax description (#3036)
Removed reference to it being experimental. Changed link to MDN. Mentioned version where it was added.
1 parent c9b9900 commit d58e9d0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

content/docs/optimizing-performance.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,14 +371,16 @@ function updateColorMap(colormap) {
371371

372372
`updateColorMap` now returns a new object, rather than mutating the old one. `Object.assign` is in ES6 and requires a polyfill.
373373

374-
There is a JavaScript proposal to add [object spread properties](https://github.com/sebmarkbage/ecmascript-rest-spread) to make it easier to update objects without mutation as well:
374+
[Object spread syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) makes it easier to update objects without mutation as well:
375375

376376
```js
377377
function updateColorMap(colormap) {
378378
return {...colormap, right: 'blue'};
379379
}
380380
```
381381

382+
This feature was added to JavaScript in ES2018.
383+
382384
If you're using Create React App, both `Object.assign` and the object spread syntax are available by default.
383385

384386
When you deal with deeply nested objects, updating them in an immutable way can feel convoluted. If you run into this problem, check out [Immer](https://github.com/mweststrate/immer) or [immutability-helper](https://github.com/kolodny/immutability-helper). These libraries let you write highly readable code without losing the benefits of immutability.

0 commit comments

Comments
 (0)