0 votes
in ReactJS by

How to use React label element?

1 Answer

0 votes
by

If you try to render a <label> element bound to a text input using the standard for attribute, then it produces HTML missing that attribute and prints a warning to the console.

<label for={'user'}>{'User'}</label>
<input type={'text'} id={'user'} />

Since for is a reserved keyword in JavaScript, use htmlFor instead.

<label htmlFor={'user'}>{'User'}</label>
<input type={'text'} id={'user'} />

Related questions

0 votes
asked Feb 24, 2021 in ReactJS by SakshiSharma
0 votes
0 votes
asked Mar 3, 2020 in ReactJS by miceperry
...