I have a reaction component (let it be called Logs) that includes another reaction component (let it be called DateChanger), which, say, for the sake of this example, serves only to change the date of the parent component, And when Logs receives the date change, it does asynchronous a call to update its own state with data from the server:
class Logs extends React.Component {
....
onDateChange(newDate) {
this.setState({loading: true, date: newDate});
asyncCall(newDate)
.then(results => {
this.setState({data: results, loading: false})
});
}
render() {
return (
....
<DateChanger onChange={this.onDateChange}>
....
)
}
}
The problem I am facing is that if someone changes the date twice twice, the render data does not always match the correct date.
, DateChanger , 1 , . , , - "" , 4-, , .
asyncCall - 4-, 3-, 4- , , 4-, 4-, .then.
React, , , , ?
[edit] setState. asyncCall setState, . (, asyncCall setState, - )