Svelte · Junior · Question 31 of 76
How does a child component tell its parent that something happened in Svelte 5?
<!-- Child.svelte -->
<script>
let { onsave } = $props();
</script>
<button onclick={() => onsave("data")}>Save</button>- ✓Correct answer: By calling a callback function passed as a prop
- 2Only with
createEventDispatcher - 3By mutating the parent's state directly
Explanation
createEventDispatcher is deprecated in Svelte 5. Callback props are simpler and fully typed.