I am using React and I need advice on the best way to filter dates in a JSON object that is populated from a fetch call to an API.
I have a Date range picker component that sets the state with the chosen dates. at page load the the data is populated into an HTML table, when the user selects the chosen dates from the date range picker and clicks the filter button I need the html table to be updated with results that fall between the chosen date ranges.
my constructor has the starting state:
this.state = {
bookings: {},
selectionRange : {
startDate: new Date(),
endDate: new Date(),
key: "selection"
}
}
My Date Button to filter the dates, my attempt to convert the date from a string to a valid date.
onbuttonsubmit() {
var options = { year: 'numeric', month: 'long', day: 'numeric' };
console.log("Testing:", new Date(this.state.bookings.FromDate).toLocaleDateString([],options));
}
<button onButtonSubmit={this.onbuttonsubmit}>Filter Dates</button>
I have attached an image showing the bookings{} json:

FromDateto be between the date range?