Svelte: OnMount lifecycle hook run in wrong sequence between parent and child components

Created on 5 Mar 2020  路  3Comments  路  Source: sveltejs/svelte

The problem
Since 3.6.4 version we have a wrong sequence for onMount lifecycle hook.
It run onMount callback first on a child component, instead of parent.

To Reproduce
https://svelte.dev/repl/9eb25e5039844a9588cd96bc7380e672?version=3.6.4

Expected behaviour
Take a look at the console.
Im expect this order for hooks calls:

onMount Parent
onMount Child

Instead we got:

onMount Child
onMount Parent

All 3 comments

yes the child get mounted first, before the parent.

this is intended.

see https://github.com/sveltejs/svelte/issues/2281

yes the child get mounted first, before the parent.

this is intended.

see #2281

this is not the same behavior

@tanhauhau i saw that issue.
It seems like when you fixed that problem you created a new. But much more bigger.

How can you mount an element to a void, can you explain pls?
Where do you mount a child component if you didn't mount its parent yet?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Rich-Harris picture Rich-Harris  路  3Comments

AntoninBeaufort picture AntoninBeaufort  路  3Comments

matt3224 picture matt3224  路  3Comments

st-schneider picture st-schneider  路  3Comments

davidcallanan picture davidcallanan  路  3Comments