react: Warning: Unknown DOM property for. Did you mean htmlFor?
I get this warning whenever I attempt to use the for
property on a <label>
element. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label for a description of the for
attribute.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 23
- Comments: 19 (5 by maintainers)
Commits related to this issue
- Support the "for" attribute on labels see https://github.com/facebook/react/issues/1819 — committed to pugjs/react-jade by ForbesLindesay 10 years ago
- fix React JSX Error for 'for' props in label tag Replace for with htmlFor in label props https://github.com/facebook/react/issues/1819 — committed to ali-master/smooch-js by ali-master 7 years ago
- Use htmlFor prop in label tag (#501) Replace for with htmlFor in label props https://github.com/facebook/react/issues/1819 — committed to zendesk/sunshine-conversations-web by ali-master 7 years ago
- Use htmlFor in example in Checkbox docs. Since it's JSX I don't think you can use "for". Some details are here: https://github.com/facebook/react/issues/1819 — committed to nworden/material-components-web-react by nworden 6 years ago
- Use htmlFor instead of for https://github.com/facebook/react/issues/1819 https://reactjs.org/docs/dom-elements.html#supported-attributes madliberation-99 — committed to douglasnaphas/madliberationjs by douglasnaphas 5 years ago
if you’re using JSX you suppose to use
htmlFor
instead offor
you can find about it here in the docs
react htmlFor
https://facebook.github.io/react/docs/dom-elements.html#htmlfor
I find this Error message counter intuitive
Looking at:
Any Wev developer new to React (or using this attribute in JSX for the 1st time) will think
Looking at the number of projects linking to this issue is a good hint to see what I mean.
A more accurate Error message could be something like
This would more rapidly point to the right direction
Sorry for the confusion! I hope the docs cleared up our reasoning (I would have linked you to the note in this part of the docs)