I have a react component, In which I am using a date picker. Based on value of Date selected I am sending an ajax request to fetch data. I am not using any frameworks like redux or flux.
export default class MyComponent extends Component {
constructor(props) {
super(props);
}
componentDidMount() {
// Initial fetch request based on the default date
}
onDateSelectionChanged(fromDate, toDate) {
this.setState({
fromDate,
toDate
});
}
render() {
return (
<div className="row">
<DateRangePicker callBackParent = {this.onDateSelectionChanged}/>
{/* other stuff */}
</div>
);
}
}
Now suppose I changed the date to another date. What is the best way to fetch the data again? should I fire request again inonDateSelectionChanged
or is there any life-cycle method?