How to improve performance in my code?
Like commented in code I think this line slows down execution . But I havent been able to figure out how to create in child component from parent component efficiently when is true in parent component.
5 Replies
// props.shown?.includes(ref) , this I believe slows down execution
what do you mean?
I think it's just not gonna be reactiveI think it gets rerun everytime shown gets set in parenti component
if you run it outside of the effect it won't track, so it's a bug, not performance issue
do you need to recreate
new PieChart
every time the element becomes visible/invisible?
how is it used btw?No, only create if it doesnt exist and is intersecting
piechart gets id as parameter and it attaches it .id in div
So would the reactivity work better if observer = new intersectionObser,... was inside effect?
but it sounds like it would just create new intersection obs instances
I don't think there is anything wrong about the observer.
You can call
onCleanup
inside onMount
to not hoist the variable maybe