Big function in parent or in children component? #17413
Replies: 1 comment
-
|
Good question! The answer really depends on what data you need and how you want to use it. If all players share the same query:Put If each player needs their own query:Put Performance-wise:Don't worry too much about function creation overhead. JavaScript engines are incredibly fast at creating functions, and Svelte 5's reactivity system is optimized for this. The real performance consideration is network requests, not function instances. The
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a component parent (Team.svelte) and a component children (Player.svelte).
The question: can I create a big function like the one below in the child components or should I create it in the parent and pass down it as prop to al children?
I mean for best performances what is the correct way?
Or should I create it in a
module=contextof the children component (but maybe is not possible because I need some variables)?I'm worried to create it in the children (Player.svelte) component because I'm afraid it gets created for each player at runtime instead of one time only in the parent (Team.svelte).
What is the idiomatic way in Svelte 5?
Beta Was this translation helpful? Give feedback.
All reactions