A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://svelte.dev/docs/svelte/legacy-svelte-self below:

<svelte:self> • Docs • Svelte

The <svelte:self> element allows a component to include itself, recursively.

It cannot appear at the top level of your markup; it must be inside an if or each block or passed to a component’s slot to prevent an infinite loop.

<script>
	export let count;
</script>

{#if count > 0}
	<p>counting down... {count}</p>
	<svelte:self count={count - 1} />
{:else}
	<p>lift-off!</p>
{/if}

This concept is obsolete, as components can import themselves:

App

<script>
	import Self from './App.svelte'
	export let count;
</script>

{#if count > 0}
	<p>counting down... {count}</p>
	<Self count={count - 1} />
{:else}
	<p>lift-off!</p>
{/if}
<script lang="ts">
	import Self from './App.svelte'
	export let count;
</script>

{#if count > 0}
	<p>counting down... {count}</p>
	<Self count={count - 1} />
{:else}
	<p>lift-off!</p>
{/if}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4