Skip to content
Justice Tech School

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

Which attribute links label to input in JSX?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.