Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
How can I save selected filter values using session storage? I want to store the selected filter value even if the user refreshes the page

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]);
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

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.

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!