React · Middle · Question 26 of 75

What is useId for?

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.

Further reading

Problem with a question

React · Middle · question 26

Test yourself

Take the React · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz