Closed fkling closed 5 days ago
I've simplified the situation in the repl linked below and what stood out to me is that b is not initialized as $.mutable_state(). So this might be less about stores and more about b not being detected as mutable. Interestingly it works within a single component.
What is b
in your example?
This is because currentStore is actually never read so while it's reassigned it's mistakenly never considered a mutable.
Basically since that is a store you are always reading $currentStore
and never currentStore
. So we need to fix the logic for that.
@trueadm @paoloricciuti already mentioned it but for completeness: currentStore
Describe the bug
We have the following situation: Component receives a store via prop
a
. The component also has a local variableb
which is assigned the value ofa
in response to some event. However when this happens anything that accesses$b
does not get updated. I've simplified the situation in the repl linked below and what stood out to me is thatb
is not initialized as$.mutable_state()
. So this might be less about stores and more aboutb
not being detected as mutable. Interestingly it works within a single component.In our real world example we receive an observable from a SvelteKit page data loader and we assign this observable to another local variable once another promise is done loading.
This code works in Svelte 4.
Reproduction
https://svelte.dev/playground/a6ca4f7f1ed84860b98793a571f9ff4d?version=5.1.11
Logs
No response
System Info
Severity
blocking an upgrade