Skip to content

Update to Svelte 5.25.0 and update "Sverdle" demo to use writable derived #487

Closed
@mdnahas

Description

@mdnahas

Describe the bug

I wasn't sure where to report this. I couldn't find which repo had the code for the Sverdle demo app created by "npx sv create my-app".

I'm upgrading my repo from Svelte 4 to Svelte 5 and am not sure how to use runes. I installed the demo app to see what it did. In file /src/routes/sverdle/+page.svelte there is this code:

        /** The current guess */
	// svelte-ignore state_referenced_locally
	let currentGuess = $state(data.guesses[i] || '');

	$effect(() => {
		currentGuess = data.guesses[i] || '';
	});

This violates the advice on this page: "Generally speaking, you should not update state inside effects, as it will make code more convoluted and will often lead to never-ending update cycles"

I'm still not sure how to use runes. Sigh.

Reproduction

Run "npx sv create my-app"
Open my-app/src/routes/sverdle/+page.svelte
Observe lines 22 to 29.

Logs

System Info

N/A

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions