class About extends React.Component<{},{}>{
Format = () => {
return(
<div>
{this.props.children}
</div>
)
}
Type1 = () => {
return(
<this.Format>
<div>...</div>
</this.Format>
)
}
}
我正在尝试将 <div>...</div>
传递到 Format 组件中,但出现错误:Type '{ children: Element[]; }' has no properties in common with type 'IntrinsicAttributes'
,关于这种情况我找不到太多相关信息。
答案 0 :(得分:2)
找到答案,必须传入 props 作为参数,因为 this.props 指的是类 props 而不是函数 props。
Format = (props) => {
return(
<div>
{props.children}
</div>
)
}