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

Form.useWatch: a detached form keeps its last value, and the equality contract for Set/Map/class values is undefined

Aperta
#125 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
react, typescript
Ambito
frontend

Direzione di ricerca

Read the Form.useWatch hook and the Field.tsx equality helper, then inspect the review of #121 for context. Reproduce the detached form case and the listed value comparisons. The detached case is done when the hook returns the fresh-mount value after detachment; the equality behavior needs an explicit contract for supported value shapes and inline selectors before implementation.

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

Descrizione

Two Form.useWatch edge cases the review of #121 found and left out of that PR

1. A detached form keeps its last value

When form goes from a valid instance to undefined (<Watcher form={attached ? form : undefined} /> with attached flipping to false), the subscription effect returns early and the watcher bails on isValidForm, so the hook keeps returning the detached form's last value instead of what a fresh mount without a form returns (undefined, or selector({})). Consumers can act on data from a form they have let go of. This is the mirror of the attach case #121 fixed.

2. Change detection is JSON serialisation, so Set / Map / toJSON-less class instances are compared as {}

new Set([1]) → new Set([1, 2]), Map changes, File, NaN vs null all serialise identically and are dropped; cyclic or BigInt values hit the catch and count as changed every time. #121 tried isEqual (the helper Field.tsx uses) and reverted it: a selector returning a fresh function/URL/React element loops forever, class instances with #private state compare equal, key order and Set order stop being reported, and equalUnordered is O(n²) on large Sets. A deliberate equality contract for useWatch (which shapes are compared how, what an inline selector may return) is needed before changing it; today's behaviour matches upstream.

Found during the review of #121.

Lingua principale
TypeScript
Stelle
2
Fork
0
Merge medio
1g 14h
PR unite (30g)
36

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 lablup/ui-common

Tutte le issue di lablup/ui-common

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.