[英]error TS2339: Property 'for' does not exist on type 'HTMLProps<HTMLLabelElement>'
Using typescript and react with TSX files with definitely typed type definitions, I am getting the error: 使用typescript并对具有明确类型定义的TSX文件做出反应,我收到错误:
error TS2339: Property 'for' does not exist on type 'HTMLProps<HTMLLabelElement>'.
When trying to compile a component with the following TSX 尝试使用以下TSX编译组件时
<label for={this.props.inputId} className="input-label">{this.props.label}</label>
I have already solved but adding here for the next person since the solution didn't show up anywhere when searching (Google or StackOverflow) 我已经解决了,但在这里为下一个人添加,因为解决方案在搜索时没有出现在任何地方(Google或StackOverflow)
The solution was to change the for
attribute to htmlFor
解决方案是将for
属性更改for
htmlFor
<label htmlFor={this.props.inputId} className="input-label">{this.props.label}</label>
This is a part of the React library itself which apparently handles for
differently just like it does class
(it uses className
) and not an issue with the definitely typed type definitions. 这是阵营库本身,这显然处理的一部分, for
不同就像它class
(它使用className
),而不是一个问题与绝对输入类型定义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.