[英]Flow.js and React
我正在嘗試將Flow與React和一起使用。 我遇到了兩個錯誤:
錯誤:導入“ ../../assets/css/clientStyle.css”; =>找不到所需的模塊
錯誤屬性sortByLastChangedDate
不兼容:15:const TableComponent =(props:道具)=> {^^^^^^屬性sortByLastChangedDate
。 找不到屬性。請參閱:src / components / client / TableComponent.js:15
。
import '../../assets/css/clientStyle.css';
type Props = { /* ... */ };
type State = {
showClients: boolean,
data: any[],
lastCreated: any[],
};
@observer
export default class Client extends React.Component<Props, State> {
constructor() {
super();
this.state = {
showClients: false,
data: [],
lastCreated: [],
};
}
render() {
return (
<TableComponent
data={this.state.data}
isHeaderWithIcons="true"
title="some title"
sortByCreationDate={this.sortByCreationDate}
sortByLastChangedDate={this.sortByLastChangedDate}
/>
)
}
}
// TableComponent
type Props = {
data: any[],
title: any,
isHeaderWithIcons: string,
sortByCreationDate: () => mixed,
sortByLastChangedDate: () => mixed,
}
const TableComponent = (props: Props) => {
return (
<div className="clients-container">
<h3>{props.title}</h3>
</div>
}
要解決導入錯誤,您將需要按照名稱映射器文檔中所述修改您的.flowconfig
文件
您的另一個錯誤是有問題的,因為您正在傳遞未定義的函數。 未在Client
定義this.sortByLastChangedDate
。 您可能是指this.props.sortByLastChangedDate
(我不確定,因為您沒有在上面包含Client
的道具)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.