useId and useLayoutEffect
useId makes stable ids. useLayoutEffect runs before paint.
Example
function Field() {
const id = useId();
return (
<>
<label htmlFor={id}>Name</label>
<input id={id} />
</>
);
}Exercise
Link a label.
<label ={id}>
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.