Skip to content

Svelte 5: Reference to derived function does not trigger effect #13354

Answered by paoloricciuti
dnass asked this question in Q&A
Discussion options

You must be logged in to vote

The render functions run in a specific order. If the changed function is called in an effect, that will happen first, and then trigger every other function to re-render in order (including the changed function, at its actual position in the sequence). The upshot is that each changed render function would run twice per frame instead of once.

Maybe I'm missing something but something like this could work I think

I've used a set but you could just as well use an array if you want to insert in specific places. Basically the point is: you shouldn't use the effect to trigger the chained render but just call every render in an effect... everytime something changes the whole chain will be rerun

Replies: 9 comments 10 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
10 replies
@paoloricciuti
Comment options

@dnass
Comment options

@paoloricciuti
Comment options

@dnass
Comment options

@dnass
Comment options

Answer selected by dnass
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants
Converted from issue

This discussion was converted from issue #13352 on September 20, 2024 20:20.