File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed
documentation/docs/02-runes Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff 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
7474class 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
111110class 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 = () => {++ +
You can’t perform that action at this time.
0 commit comments