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

Most upvoted comments

if you’re using JSX you suppose to use htmlFor instead of for

you can find about it here in the docs

I find this Error message counter intuitive

Looking at:

Warning: Unknown DOM property for. Did you mean htmlFor?

Any Wev developer new to React (or using this attribute in JSX for the 1st time) will think

WTF! how can the DOM <label> "for" property be Unknown! It’s been here for ages !

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

Warning: Unknown JSX property for. Did you mean htmlFor?

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)