update docs

pull/15820/head
Rich Harris 4 months ago
parent ae7e5bbe3f
commit 670a7e1de3

@ -67,16 +67,15 @@ todos[0].done = !todos[0].done;
### Classes ### Classes
You can also use `$state` in class fields (whether public or private): You can also use `$state` in class fields (whether public or private), or as the first assignment to a property immediately inside the `constructor`:
```js ```js
// @errors: 7006 2554 // @errors: 7006 2554
class Todo { class Todo {
done = $state(false); done = $state(false);
text = $state();
constructor(text) { constructor(text) {
this.text = text; this.text = $state(text);
} }
reset() { reset() {
@ -110,10 +109,9 @@ You can either use an inline function...
// @errors: 7006 2554 // @errors: 7006 2554
class Todo { class Todo {
done = $state(false); done = $state(false);
text = $state();
constructor(text) { constructor(text) {
this.text = text; this.text = $state(text);
} }
+++reset = () => {+++ +++reset = () => {+++

Loading…
Cancel
Save