You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Disallows referencing let/var variables in templates.
6
+
7
+
```js
8
+
// app/components/foo.gjs
9
+
let foo =1;
10
+
11
+
functionincrement() {
12
+
foo++;
13
+
}
14
+
15
+
exportdefault<template>{{foo}}</template>;
16
+
```
17
+
18
+
This does not "work" – it doesn't error, but it will essentially capture and compile in the value of the foo variable at some arbitrary point and never update again. Even if the component is torn down and a new instance is created/rendered, it will probably still hold on to the old value when the template was initially compiled.
19
+
20
+
So, generally speaking, one should avoid referencing let variables from within <template> and instead prefer to use const bindings.
0 commit comments