Here's the filter that I have set up so far. But I am having trouble finding a way to store the selected values. Should I be using local storage or session storage for what I am trying to achieve here?
const [filter, setFilter]= React.useState<AssignedFilterTypes>(AssignedFilterTypes.All);
const res = content.filter(c => c.percentage !== 100).sort((a, b) => compare(a, b, sort));
const storedFilter = sessionStorage.setItem('storedFilter',filter)
if(statistics && filter !== AssignedFilterTypes.All) {
return res.filter((c) => statistics[c.id].num_users);
}
return res;
}, [sort, showContent, filter, courses, programs, packages]);
Session storage gets cleared when the tab is closed. It persists when the page reloads, though. If you don't want to lose the data when the browser is closed, you need local storage. Note that if you are in a private window, it will clear after you close it.