-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Bug: the first template render happens before onstate
#1522
Comments
fixed in 2.11. Hopefully wasn't a breaking change... |
@Rich-Harris spoilers: it was 😭 |
@kaisermann we already solved this in chat, but I'm documenting the solution here for posterity. If you experience any breaking changes, it is likely because you are modifying/accessing the DOM inside The fix is to put anything that relies on the DOM (any references to |
@jacwright I guess we should put this somewhere in the
It's not clear enough for this case 🤔 |
Good point. Do it! Doooo eeeet. Or I will if I remember. |
I added a rule to It's in v1.2.0 |
onstate before render
onstate
should be called before every render, but it is not called before the initial render. It is called before every subsequent render though, so that's good, but it needs to run before the first (I think). If it doesn't there is no way to change the data before that initial render sinceoncreate
also happens after the initial render and afteronstate
.See https://svelte.technology/repl?version=2.7.0&gist=15eb8d37be3fefa75497b94fd19fec44
The text was updated successfully, but these errors were encountered: