Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

useSessionStorage is tied up to a component state and not to SS

Aberta
#2,597 1 comentário 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
35/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
react, typescript
Domínio
frontend

Direção de pesquisa

Start with the linked CodeSandbox reproduction and the useSessionStorage hook entry point, then inspect how updates from ComponentA and ComponentB are persisted under the shared myKey. Done means updating one property preserves the other property's stored array, matching the expected session-storage shape described in the issue.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

What is the current behavior?

I have an object with the following signature:

type Value = {
    a: string[],
    b: string[]
}

And the two components ComponenA and ComponentB and SS key myKey. Whenever user clicks on ComponentA value.a should be updated in SS and value.b should not be overridden. Actually useSessionStorage overrides the SS value depending on which component was clicked last. For example user cliked several times on both components, the SS value is:

  {
    b: ["Value B", "Value B", "Value B", "Value B"],
  };

CodeSanbox

What is the expected behavior?
The SS should be updated for the myKey. Say user clicked several times on both components then SS value should look something like:

 {
    a: ["Value A", "Value A", "Value A", "Value A"],
    b: ["Value B", "Value B"],
  };

A little about versions:

  • OS: Windows
  • Browser (vendor and version): Chrome
  • React: 18+
  • react-use: 17.5.1
Linguagem predominante
TypeScript
Estrelas
44k
Forks
3.3k
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de streamich/react-use

Todas as issues de streamich/react-use

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.