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 ### Updating arrays and objects
#### ✗ Bad
```js ```js
this.names = [ this.names.push('Larry') // ⚠️
...this.names, this.options.show = true // ⚠️
'Larry'
]
``` ```
#### ✓ OK
```js ```js
this.options = { this.names = [ ...this.names, 'Larry' ]
...this.options, this.options = { ...this.options, show: true }
visible: true
}
``` ```
Mutable operations such as `push()` won't work. You'll need to assign a new copy. Mutable operations such as `push()` won't work. You'll need to assign a new copy.