-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Labels
Description
TLDR
https://svelte.dev/docs/svelte/snippet#Passing-snippets-to-components
Would like to add a section to explain the direct/explicit
method
let { foo } = $props();
{@render foo()}
Explanation
As far as i can tell there are 3 ways, and the second one direct/explicit
doesn't seem to be mentioned at all.
Currently is unclear what the various snippet options are in comparison to its counterpart {#if...}
and {#each...}
- direct/implcicit
// Parent.svelte
<Child>
<h1>Title!</h1>
</Child>
// Child.svelte
<script>
let { children } = $props();
</script>
{@render children()}
- direct/explicit
// Parent.svelte
<Child>
{#snippet foo()}
<h1>Title!</h1>
{/snippet}
</Child>
// Child.svelte
<script>
let { foo } = $props();
</script>
{@render foo()}
- indirect/explicit
// Parent.svelte
{#snippet foo()}
<h1>Title!</h1>
{/snippet}
<Child {foo} />
// Child.svelte
<script>
let { foo } = $props();
</script>
{@render foo()}
Reference
https://discord.com/channels/457912077277855764/1300850418728960000
Severity
annoyance