svelte icon indicating copy to clipboard operation
svelte copied to clipboard

More documentation about non working reactivity

Open GauBen opened this issue 2 years ago • 0 comments

Describe the bug

I often hear from other developers having issues with reactive statements doing nothing. For instance:

<script>
	export let data; // We use sveltekit
	
	$: me = data.me;
	$: hasThing = me.things.length > 0

	setContext('hasThing', hasThing); // hasThing is always undefined??
</script>

This won't work, and this behavior is documented:

image

https://svelte.dev/docs#component-format-script-3-$-marks-a-statement-as-reactive

I feel that this documentation is a bit underwhelming considering how often I hear about this problem.

What could help:

  • A compiler warning
  • A dedicated tutorial page
  • A dedicated block in the documentation, around https://svelte.dev/docs#component-format-script-3-$-marks-a-statement-as-reactive
  • An eslint rule
  • You name it

Reproduction

Logs

No response

System Info

-

Severity

annoyance

GauBen avatar Jun 08 '23 09:06 GauBen