流打字功能

时间:2019-07-16 10:24:40

标签: reactjs flowtype

我想养成正确流式输入所有内容的习惯。我输入了一些函数,如下所示:

handleStartDateClick = (event: SyntheticEvent<HTMLElement>) => {
  event.stopPropagation();
  this.setState({ selectDate: SELECT_DATE.START });
};

handleEndDateClick = (event: SyntheticEvent<HTMLElement>) => {
  event.stopPropagation();
  this.setState({ selectDate: SELECT_DATE.END });
};

我有点不确定此函数的类型:

handleClearDates = (startDate, endDate) => (event) => {
  event.stopPropagation();
  if (startDate || endDate) {
    this.props.client.writeData({
      data: {
        selectedDates: [],
      },
    });

    this.setState(() => ({
      selectDate: SELECT_DATE.START,
    }));
  } else {
    this.handleDayPickerClose();
  }
};

任何帮助/建议都很棒!

1 个答案:

答案 0 :(得分:1)

考虑询问Flow的不和https://discord.gg/8ezwRUK

handleClearDates = (startDate: Date, endDate: Date) => (event: SyntheticEvent<>) => {
  event.stopPropagation();
  if (startDate || endDate) {
    this.props.client.writeData({
      data: {
        selectedDates: [],
      },
    });

    this.setState(() => ({
      selectDate: SELECT_DATE.START,
    }));
  } else {
    this.handleDayPickerClose();
  }
};