Reputation: 3723
I am creating a ReactJS component with a search field described like this:
SearchNotes.js
<label for='search_notes'>Search</label>
<input id='search_notes' type='text' onKeyPress={this.handleKeyPressed}></input>
Everything is working fine, but I am getting this error here:
This property for
clearly exists in label
tags. What am I missing here?
Upvotes: 0
Views: 58
Reputation: 10548
The error is occurring because for
is not an attribute on React elements. Use htmlFor
instead, as the error suggests. React doesn't use any JavaScript keywords as attribute names like class
(which is className
) or for
(which is htmlFor
).
Upvotes: 2