React-js ignores label's 'for' attribute

后端 未结 2 1088
深忆病人
深忆病人 2021-02-04 23:24

I know that for \'class\' we must use className, but how do i get react to preserve \'for\' attribute?

The following:

2条回答
  •  长发绾君心
    2021-02-04 23:44

    for is a keyword in javascript so in JSX you can't use it. You must use htmlFor which is translated into for attribute once it is rendered to the DOM.

提交回复
热议问题