Skip to content

More documentation about non working reactivity #8707

@GauBen

Description

@GauBen

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:

Reproduction

Logs

No response

System Info

-

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions