Skip to content

Commit 670a7e1

Browse files
committed
update docs
1 parent ae7e5bb commit 670a7e1

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

documentation/docs/02-runes/02-$state.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,15 @@ todos[0].done = !todos[0].done;
6767

6868
### Classes
6969

70-
You can also use `$state` in class fields (whether public or private):
70+
You can also use `$state` in class fields (whether public or private), or as the first assignment to a property immediately inside the `constructor`:
7171

7272
```js
7373
// @errors: 7006 2554
7474
class Todo {
7575
done = $state(false);
76-
text = $state();
7776

7877
constructor(text) {
79-
this.text = text;
78+
this.text = $state(text);
8079
}
8180

8281
reset() {
@@ -110,10 +109,9 @@ You can either use an inline function...
110109
// @errors: 7006 2554
111110
class Todo {
112111
done = $state(false);
113-
text = $state();
114112

115113
constructor(text) {
116-
this.text = text;
114+
this.text = $state(text);
117115
}
118116

119117
+++reset = () => {+++

0 commit comments

Comments
 (0)