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

useMeasure dimensions out of sync in react18

Aperta
#2,522 2 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 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 by locating the useMeasure implementation and its ResizeObserver state update, then reproduce the React 18 timing issue using the linked CodeSandbox. Compare the behavior with React's flushSync guidance and define whether synchronization is always applied or exposed as opt-in; done means dimensions are reliable for visual updates and the behavior is covered by appropriate tests.

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

Descrizione

React version: 18

Due to automatic batching in react18, state updates in useMeasure's ResizeObserver may be applied after paint. This can cause visual glitches if we depend on useMeasure dimensions for visual updates.

Same issue is raised in react: https://github.com/facebook/react/issues/24331

They are recommending that state updates in ResizeObserver should be wrapped in flushSync from ReactDOM.

Can we do this in useMeasure or at least add optional support for flushSync in useMeasure. So that consumers can opt-in if they are using the dimensions for visual update(For eg. in useLayoutEffect).

Link to code example: https://codesandbox.io/s/amazing-montalcini-j6lz46?file=/src/App.js

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.