In React (Facebook’s framework), I need to render a label element bound to a text input using the standard
e.g. the following JSX is used:
<label for="test">Test</label> <input type="text" id="test" />
However, this produces HTML missing the required (and standard)
<label data-reactid=".1.0.0">Test</label> <input type="text" id="test" data-reactid=".1.0.1">
What am I doing wrong?
for attribute is called
htmlFor for consistency with the DOM property API. If you’re using the development build of React, you should have seen a warning in your console about this.
Yes, for react,
for becomes htmlFor
class becomes className
see full list of how HTML attributes are changed here:
just using react
htmlFor to replace
you can find more info by following the below links.
For React you must use it’s per-define keywords to define html attributes.
is used and
is used, as react is case sensitive make sure you must follow small and capital as required.