EsLint rule for label

Case 1: You can make input inside label

  <label>
      <input type="text"/>
  </label>

case 2: use htmlFor

   <label htmlFor="first-name">
        First Name
   </label>
   <input type="text" id="first-name" />
 

you can go through the details of rules through this page:

Edit:

According to docs:

Case: The label is a sibling of the control.

<label htmlFor={domId}>Surname</label>
<input type="text" id={domId} />

Leave a Comment