{#if val}
<div>Content</div>
{/if}
How do I call a function after the div is rendered?
You can add an attachment or an action (in older Svelte versions) to the div.
{#if val}
<div {@attach div => console.log(div.textContent)}>
Content
</div>
{/if}