HiveBrain v1.2.0
Get Started
← Back to all entries
patternreactCritical

React ignores 'for' attribute of the label element

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
ignoresthereactattributeforlabelelement

Problem

In React (Facebook's framework), I need to render a label element bound to a text input using the standard for attribute.

e.g. the following JSX is used:

Test


However, this produces HTML missing the required (and standard) for attribute:

Test


What am I doing wrong?

Solution

The 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.

Context

Stack Overflow Q#22752116, score: 802

Revisions (0)

No revisions yet.