[英]eslint+ flow : 'attribute' is missing in props validation (Object with identifier)
我今天面臨一個奇怪的問題,
我有一個用流輸入的React組件(也就是SEO的flowtype),由於某種原因,它在這里顯示輸入錯誤,這是簡化的代碼。
type Props = {
someObject: { [string]: string },
};
class ComponentOne extends React.Component<Props> {
render() {
return (
// No idea why there's a linting error, seems like a bug
<div className={this.props.someObject.someKey} />
);
}
}
const WithEnhancements = enhance(magic)(ComponentOne);
export default () => (
<RenderPropComponent>
{({ someProp }) => {
return <WithEnhancements someProp={someProp} />;
}}
</RenderPropComponent>
);
錯誤是'someObject.someKey' is missing in props validation
。 我快要撞牆了,不知道可能是什么原因造成的,在其他組件中使用相同數據結構的相同類型輸入絕對可以,這可能是eslint
對多組件文件不滿意的錯誤嗎?
更新:好像是一個臭蟲錯誤,由於某種原因,當像這樣分解道具然后使用someObject.someKey
時,它可以工作:
const { someObject } = this.props;
目前,這是一個臭蟲,請在此處報告。 可以通過破壞frontendgirl所提到的道具來補救,盡管這看起來似乎不是干凈的代碼,但您只需要對具有地圖對象的組件(帶有索引器屬性的組件, { [string]: string }
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.