簡體   English   中英

Flow.js和React

[英]Flow.js and React

我正在嘗試將Flow與React和一起使用。 我遇到了兩個錯誤:

  1. 錯誤:導入“ ../../assets/css/clientStyle.css”; =>找不到所需的模塊

  2. 錯誤屬性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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM