Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

186
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda