私は日付範囲に基づいてデータを表示するフォームを持っています。初めてのロードでは、>過去1時間のデータが表示されます。私は、開始日と終了日をレンダリングするために、反応日>>>ピッカーを使用しています。ユーザーが開始日と終了日を変更すると、以下の関数が呼び出されます。この機能では、私は、ユーザーが選択した開始日と終了日で>>>状態を設定しようとしていますが、状態は常に>>>以前の開始日と終了日の値React - this.setStateとthis.forceUpdateは、最新の値を保持するために状態を更新しません。
refreshTableOnDateChange(startDateSelected,endDateSelected) {
this.setState({startDate: null, endDate: null});
console.log("inside refreshTableOnDateChange this.state.startDate is", startDateSelected);
console.log("inside refreshTableOnDateChange this.state.endDate is", endDateSelected);
let startDateFormatted = startDateSelected.format('YYYY-MM-DD HH:mm');
let endDateFormatted = endDateSelected.format('YYYY-MM-DD HH:mm');
this.setState({startDate: startDateFormatted, endDate: endDateFormatted});
this.forceUpdate();
console.log("start date is", this.state.startDate);
console.log("end date is", this.state.endDate);
this.load(this.state.orderType);
}