首页 文章

Flow.js和React

提问于
浏览
0

我试图使用Flow with React和 . 我收到这两个错误:

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

  • 错误属性 sortByLastChangedDate 不兼容:15:const TableComponent =(props:Props)=> {^^^^^ property 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>
}

1 回答

  • 0

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

    您的其他错误是有问题的,因为您通过了未定义的函数 . this.sortByLastChangedDate 未在 Client 上定义 . 你可能意味着 this.props.sortByLastChangedDate (我可以't know for sure since you didn'包括上面 Client 的道具) .

相关问题