Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic SvelteKit / API routes / POST handlers: tutorial does not function as written. #786

Open
danloomer opened this issue Nov 3, 2024 · 3 comments

Comments

@danloomer
Copy link

danloomer commented Nov 3, 2024

https://svelte.dev/tutorial/kit/post-handlers

This tutorial does not seem to be up to date with the current framework behavior.

There are a couple incongruencies:

  1. Following the tutorial you end up with an input that creates todos on enter keydown, but the UI does not update until you refresh.
  2. Pressing the solve button adds a $bindable() rune to the data prop, but this is not mentioned anywhere in the tutorial, and does not actually seem to be necessary or make a difference.

I think the issue is that the example is trying to deeply mutate the data prop, but it's not a reactive prop, so it does not detect the change. Changing data update line from data.todos to a full reassignment of data fixes the example.

Screen.Recording.2024-11-03.at.2.58.37.PM.mov
@danloomer
Copy link
Author

danloomer commented Nov 3, 2024

The issue continues on the next page, because it builds on the previous non-functioning code:
https://svelte.dev/tutorial/kit/other-handlers

Need to refresh to see added/deleted todos.

I also noticed that the arial-abel is a bit odd on the delete button: Mark as complete
image

Solve does not work here either.

@KamBha
Copy link

KamBha commented Dec 7, 2024

I was able to make this work by creating a $state variable:-

let results = $state(data.todos);

And then using results instead of data.todos. Is the standard/correct way of doing things?

@lts20050703
Copy link

Seems like the tutorial was updated!

https://svelte.dev/tutorial/kit/post-handlers

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants