Svelte · Middle · Question 58 of 75
What does $props.id() (Svelte 5.20+) generate?
<script>
const uid = $props.id();
</script>
<label for="{uid}-email">Email</label>
<input id="{uid}-email" />- ✓Correct answer: An id unique to the component instance that is the same during SSR and hydration, handy for linking labels and ARIA attributes
- 2The id of the parent component
- 3A random id that changes on every render
Explanation
Random ids generated with Math.random() would differ between server and client and break hydration.