Coding task · JavaScript and React course · Module 9: Modern React Hooks

Practice: useId - Forms with Accessibility

useId() returns an identifier that is unique for every component instance and the same in every render. A label connects to a field through htmlFor equal to the field id, and aria-describedby points to the id of the element with the description.

Task

The crew registration form consists of three CrewField fields. Every field has a label and a helper text, and the component can appear on the screen many times. Fill in the blanks: ___BLANK1___ is the React hook that generates a unique and stable identifier for this instance of the field, ___BLANK2___ is the identifier the label points to through htmlFor, and ___BLANK3___ is the identifier of the helper text paragraph that the field points to through aria-describedby. Clicking a label in the preview should put the cursor in the field, and two such forms on one page must not share identifiers.