Closed aradalvand closed 2 years ago
I think the root cause is the same as https://github.com/sveltejs/svelte/issues/6921
In order to decide whether to recalculate a $
part, the runtime determines if a dependent variable(s) has changed.
However, as shown in the following runtime code, object
is always considered to have changed.
Therefore a $
part is to be recalculated more than necessary.
This seems to be the intended behavior, at least from the code.
Okay but still nothing in the $$restProps
has actually changed, I think Svelte should take a smarter approach in this regard. Don't you agree?
Can you explain the benefit of eliminating this small inefficiency? I think it's possible to eliminate this inefficiency, but there is a trade-off with performance. So I think there needs to be a clear reason to implement it.
Close this because there was no clear explanation here. Nevertheless, the conservative reactivity could be improved in Svelte4.
Describe the bug
This is a small thing but I wanted to know whether it could be fixed or it was done intentionally. Here's the REPL.
What's happening here in this example is that whenever the value of the prop
rating
changes, it's as if$$restProps
is also updated, and as a result, every part of the component that's referencing$$restProps
would be notified and re-rendered, even though the contents of$$restProps
haven't changed at all.For
$$props
this would of course make sense, but not for$$restProps
since therating
prop is a normal component prop and would never be included in$$restProps
. So, any changes to it shouldn't really concern$$restProps
at all.This is a small inefficiency and I was curious as to why it happens. Thanks.
Severity
annoyance