I have a date range picker, and I want to pass the two dates (startDate, endDate) to handleFilterChange, which builds an filter object to save in session storage. Currently I try to call the function, giving parameters as two arrays, which obviously doesn't work. Calling the function twice also didn't work.
Is this thing even possible and if, then what would be a correct way to pass these two dates to this function?
handleFilterChange
const handleFilterChange = (value, title) => {
clearPreviousResults();
const newFilters = {
...filters,
[title]: value,
};
saveFilterValue(newFilters, FILTERS_STORAGE_KEY);
setFilters(newFilters)
date picker
const handleDateRangeChange = dates => {
if (!dates || dates.length <= 1) {
return;
}
handleFilterChange( ["startDate", "endDate"], [dates[0], dates[1]] );
};
I am assuming you are trying to save an object in the LocalStorage or session. I would rather send the whole dates array to handleFilterChange function.