React · Middle · Question 26 of 75
What is useId for?
- ✓Correct answer: For unique ids that match on the server and the client
- 2For generating stable
keys in lists - 3For reading a DOM element's
idattribute
Explanation
useId is handy for linking label + input, aria-describedby and the like. Math.random() would give different values during SSR and hydration, and a global counter breaks with a different render order. useId isn't suitable for list keys - keys should come from data.