Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#2,597 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
react, typescript
Ambito
frontend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
TypeScript
Stelle
44k
Fork
3.3k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di streamich/react-use

Tutte le issue di streamich/react-use

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.