stencil: clarify what not to do

This commit is contained in:
Rico Sta. Cruz 2017-10-11 12:02:54 +08:00
parent d42c52dc9b
commit a60459ca80
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
1 changed files with 7 additions and 8 deletions

View File

@ -101,18 +101,17 @@ See: [Managing component state](https://stenciljs.com/docs/decorators#managing-c
### Updating arrays and objects
#### ✗ Bad
```js
this.names = [
...this.names,
'Larry'
]
this.names.push('Larry') // ⚠️
this.options.show = true // ⚠️
```
#### ✓ OK
```js
this.options = {
...this.options,
visible: true
}
this.names = [ ...this.names, 'Larry' ]
this.options = { ...this.options, show: true }
```
Mutable operations such as `push()` won't work. You'll need to assign a new copy.