component-party.dev
component-party.dev copied to clipboard
fix Svelte 5 on-mount
$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.