component-party.dev icon indicating copy to clipboard operation
component-party.dev copied to clipboard

fix Svelte 5 on-mount

Open 7nik opened this issue 2 years ago • 0 comments

$effect() runs after the component gets mounted and rendered, but pageTitle isn't reactive. Thus, the page won't re-render with the new value. For this logic, it's better to use $effert.pre() - it runs before mounting and the first rendering. But as the example concerns the on-mount event, it makes more sense to make pageTitle reactive.

You can try both solutions on the Svelte 5 playground.

7nik avatar Nov 20 '23 20:11 7nik