-
-
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
beforeUpdate called twice with bound reference #6016
Comments
I might not have realized when I submitted them but there is one important concept change to my PR #3308.
|
It happened because of the update call on the dirty component from schedulers i.e. when variable bind to the this, svelte mark it as a dirty and call the scheduler update
In the above before_update gets called again and the same will happen if there are any reactive statements. |
The issue still exists. Tested on Svelte 3.47.0. |
The issue still exists in Svelte 3.52.0. |
Issue still exists in Svelte 3.55. Quick and hacky work-around by checking if the variable to store reference has been set: https://svelte.dev/repl/28d44e6712604fe0b52c632e313f2359?version=3.55.0
|
…n bindings are used (#142) # Motivation We disable the `<InfiniteScroll />` component `beforeUpdate` because we do want to trigger an intersection in case of layout shifting - i.e. we do not want to trigger additional unexpected query and update calls in the proposal list views. We noticed that under certain circumstances, notably when initialized while enabling at the same time, a race condition can lead to the scroller being disabled. Root cause of the problem is a Svelte issue [#6016](sveltejs/svelte#6016). Indeed, when bindings are used (`bind:this=my_HTML_element`) within the compoment, the `beforeUpdate` lifecycle is called twice while `afterUpdate` is called only once. Therefore, as we disable the scroll in the first method and enable in the second, the scroller remains disabled. # Reproduction See PR #141 [comment](#141 (comment)). # Changes - implement a workaround to ignore second `beforeUpdate` call trigger by binding initialization
This issue still exists 4.0.0. |
This issue still exists 4.0.5. |
Describe the bug
This is a duplicate of #3290 which was closed, though the issue still exists.
beforeUpdate
is called twice when usingbind:this
.Logs
No errors were shown in logs
To Reproduce
https://svelte.dev/repl/3381c9b40dc8441a8e4ebfa48fd8c178 (credit to beomy)
Open the console to view the behavior. It produces:
Expected behavior
beforeUpdate should only be called once during a single update cycle.
Severity
Severity is High, as the the cycle should always end with an
afterUpdate
and not a repeatedbeforeUpdate
.Other
#3308, was made to potentially fix this issue but appears that it was never merged. The reason given was that it was fixed in 3.18.2, but the issue still exists. https://svelte.dev/repl/3381c9b40dc8441a8e4ebfa48fd8c178?version=3.18.2.
The text was updated successfully, but these errors were encountered: