【问题标题】:Flow.js and ReactFlow.js 和反应
【发布时间】:2018-06-18 09:43:16
【问题描述】:

我正在尝试将 Flow 与 React 一起使用。 我收到这两个错误:

  1. 错误: 导入'../../assets/css/clientStyle.css'; => 未找到所需模块

  2. 错误 属性sortByLastChangedDate 不兼容: 15: const TableComponent = (props: 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>
}

【问题讨论】:

    标签: javascript reactjs flowtype


    【解决方案1】:

    要修复导入错误,您需要修改 .flowconfig 文件,如 in the docs for name mapper 所述

    您的另一个错误是有问题的,因为您传递了一个未定义的函数。 this.sortByLastChangedDate 未在 Client 上定义。你可能指的是this.props.sortByLastChangedDate(我不能确定,因为你没有包括上面Client 的道具)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-05
      • 1970-01-01
      • 2021-04-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多