Clarify why useEffect() may need exhaustive deps
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 11.8k
- Fork
- 7.9k
- Merge medio
- 1g 11h
- PR unite (30g)
- 11
Descrizione
I may be having a... moment, but in Conditionally firing an effect, is this sentence accurate?
If you use this optimization, make sure the array includes all values from the component scope (such as props and state) that change over time and that are used by the effect. Otherwise, your code will reference stale values from previous renders.
Doesn't useEffect capture the latest props and state the moment any of its dependencies change? What can happen is the effect misses some updates when things it references change and they're not included as deps, but when it does run the props and state are "fresh" (pertaining to the latest render), are they not?
(Edit: removed unrelated point)
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dalla sezione collegata “Conditionally firing an effect” e rivedi la frase sui valori provenienti dal component scope alla luce del comportamento documentato delle dipendenze di useEffect. Il lavoro è completato quando la formulazione spiega accuratamente cosa accade quando i valori referenziati vengono omessi dall’array delle dipendenze.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, react
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100