Skip to content

Commit 0dabafd

Browse files
Update README.md (sveltejs#365)
* Update README.md Added info for better clarity on undeclared variables in a reactive statement * Update README.md Added backticks to distinguish `let ` from text * Update README.md --------- Co-authored-by: Rich Harris <[email protected]>
1 parent 865c28f commit 0dabafd

File tree

1 file changed

+2
-0
lines changed
  • content/tutorial/01-svelte/02-reactivity/02-reactive-declarations

1 file changed

+2
-0
lines changed

content/tutorial/01-svelte/02-reactivity/02-reactive-declarations/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ let count = 0;
1212
+++$: doubled = count * 2;+++
1313
```
1414

15+
If a reactive statement consists entirely of an assignment to an undeclared variable, Svelte will inject a `let` declaration on your behalf.
16+
1517
> Don't worry if this looks a little alien. It's [valid](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label) (if unconventional) JavaScript, which Svelte interprets to mean 're-run this code whenever any of the referenced values change'. Once you get used to it, there's no going back.
1618
1719
Let's use `doubled` in our markup:

0 commit comments

Comments
 (0)