Open fsoft72 opened 3 days ago
You can avoid the reinvocation by using a @const
tag:
{#each list as el }
{@const component = getComponent(el)}
{@render comp(component, el)}
{/each}
I'm not sure if this warrants a fix - i.e. use a derived to deduplicate accesses - or if we can keep this as-is.
You can avoid the reinvocation by using a
@const
tag:{#each list as el } {@const component = getComponent(el)} {@render comp(component, el)} {/each}
I'm not sure if this warrants a fix - i.e. use a derived to deduplicate accesses - or if we can keep this as-is.
This is my first time seeing this. Thank you.
This solves my problem, but I think it is worth investigating more, because I discovered it only by placing some console.log()
inside my function: it could lead to very strange / unexpected behaviors.
You can avoid the reinvocation by using a
@const
tag:
Giving this the 5.0 label in the sense of "we should decide what to do here (if anything) soon"
Describe the bug
Look at the following code:
Each time
<svelte:component>
access thecomponent
attributes, internally it invokes a newcomponent()
instance. Ifcomponent()
is heavy, it results in a slowdown of the whole page render.This is the code generated by Svelte compiler:
Since I am already passing a valid Svelte component as parameter, I'd expect no new instance to be created.
Reproduction
I have created a small REPL here
This example renders 3 components, but console log shows them instantiated 6 times in total.
Logs
No response
System Info
Severity
blocking an upgrade