-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
component with transition directive didn't update correctly when store updated #4696
Comments
Not sure if it's helpful but I found if I change +$: $store[currentTab] !== 'LOADED' && new Promise(resolve => {...})
-$: $store[currentTab] !== 'LOADED' && Promise.resolve(...) You can check repl here. |
Hello, That's not exactly a resolution as you are setting a timeout in order to wait for the promise to resolve. The codes provided are slightly different, as the first snippet resolves immediately, but the second one has a timeout with 1s delay. If you set the delay to 0ms it would behave the same. The issue is that you are updating the currentTab before the store has been updated, so when the if statment passes the condition, it will not update the children because the currentTab variable is not being reassinged. A solution to that would be to either create a store that will store the currentTab as well as the loading. Or based on the current code with a small tweek if you add this reactive value:
And update the template:
This would update the children because the You can check the repl here. |
Describe the bug
When store get updated, I found component with transition directive won't update. It only happens when:
store.update()
inside Promisethen()
block, if I movestore.update()
call to outside, it works as expected.To Reproduce
demo
tab2
button, text should be updated toHello Tab2
(can check console for store detail)tab1
button againtab2
button again, it now updates.work around
Title.svelte
, removetransition:fade
, rerun itthen()
, rerun it.Expected behavior
text should be updated.
Severity
small.
The text was updated successfully, but these errors were encountered: