You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/site/content/tutorial/07-lifecycle/02-ondestroy/app-a/App.svelte

18 lines
347 B

<script>
import Inner from './Inner.svelte';
let counter = 0;
let show = true;
const toggle = () => (show = !show);
const handleTick = () => (counter += 1);
</script>
<div>
<button on:click={toggle}>{show ? 'Destroy' : 'Show'} Inner component</button>
<p>counter={counter}</p>
{#if show}
<Inner callback={handleTick} />
{/if}
</div>