Flow.js和React

时间:2018-01-09 11:04:37

标签: javascript reactjs flowtype

我正在尝试使用Flow with React和。 我收到了这两个错误:

  1. 错误: import'../../assets/css/clientStyle.css'; =>找不到所需的模块

  2. 错误 属性sortByLastChangedDate不兼容:  15:const TableComponent =(props:Props)=> {                                     ^^^^^ property sortByLastChangedDate。找不到属性。请参阅:src / components / client / TableComponent.js:15

  3. 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>
    }
    

1 个答案:

答案 0 :(得分:0)

要修复导入错误,您需要按照in the docs for name mapper

所述修改>>> my_dict = {'bananas':'3', 'apples':'10', 'pears':'9', 'grapes':'2', 'oranges':'21', 'peaches':'12'} >>> search('apples', my_dict) [('pears', '9'), ('peaches', '12')] >>> search('bananas', my_dict) [('pears', '9'), ('grapes', '2')] >>> search('grapes', my_dict) [('bananas', '3'), ('pears', '9')] 文件

您的其他错误是有问题的,因为您通过了未定义的函数。 .flowconfig未定义this.sortByLastChangedDate。您的意思可能是Client(由于您未在上面添加this.props.sortByLastChangedDate的道具,我无法确切知道。)