I’ve been using svelte since January.

It’s great, but there’s a lot of footgunning involved 😂

Reply to this note

Please Login to reply.

Discussion

Defo, just starting with it because I find it a very interesting framework. But first impressions are that better debugging tools are needed. However, I will continue exploring it together with ndk, good combo

Would love to hear more about the footgunning you're experiencing! :) Can probably bring it to the attention of the maintainers.

Been using Svelte since 2019 so a bit hard for me to put myself in the shoes of a "newcomer".

omg! we have someone that actually knows svelte in nostr???!

if I could follow you more I would, but FOLLOWED!

what always trips me is the reactivity gotchas, I get the `a = a` when you want to trigger reactivity on an array/object, but sometimes I get weirdness with the reactivity beyond that.

For example, I have a /a/[naddr]/+page.svelte that just renders a />

Is wrapping the in a {#key naddr} the right way? Without the #key svelte wouldn't react to page changes with re-rendering the

----

I'll probably run into other svelte weirdness without the next hour 😂 I'll add another response if that's cool 😀

It should re-render if naddr changes but it can depend on how you've used it inside List. It sounds like you might be making a mistake inside the List component. Here's an example I whipped up real quick: https://svelte.dev/repl/8f554eb6d505436f85c27203021ae1b3?version=4.0.5

If you look at List.svelte you'll notice that I've got two different ways of getting notes. One using the { notes } = naddr syntax and the other using the reactivity $: syntax. The reason the first one doesn't work is because *the script tag only runs once* when the component is mounted. Then it never runs again. Key works because it completely destroys the component and re-mounts it. Hopefully that sheds some clarity on the situation :)

If you can link me some code I can probably take a closer look 🤘