Svelte · Middle · Question 60 of 75

How do you render fallback content when no children snippet was passed?

{#if children}
  {@render children()}
{:else}
  <p>Nothing here</p>
{/if}

Explanation

Snippet props are just values that may be undefined; for a simple render without fallback use {@render children?.()}.

Further reading

Problem with a question

Svelte · Middle · question 60

Test yourself

Take the Svelte · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz