stencil: clarify what not to do
This commit is contained in:
parent
d42c52dc9b
commit
a60459ca80
15
stencil.md
15
stencil.md
|
@ -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.
|
||||||
|
|
Loading…
Reference in New Issue