Missing documentation of `dispatch` function's stability
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 11.8k
- Forks
- 7.9k
- Ø Merge
- 1 T. 11 Std.
- Gemergte PRs (30 T.)
- 11
Beschreibung
First, I like the new React docs a lot! Unfortunately, I can no longer find the following information about useReducer that was once available in the docs:
The useReducer hook returns an array with two elements: the current state and a dispatch function. The dispatch function is used to update the state by calling it with an action object. The dispatch function returned by useReducer has a lifecycle similar to that of the component it is used in. It is created when the component mounts and destroyed when the component unmounts. The dispatch function is guaranteed to be stable across re-renders.
Is this no longer the case?
On page Lifecycle of Reactive Effects there is a note box saying "In some cases, React knows that a value never changes..." and mentioning useState and useRef. It would be ideal if the documentation would explicitly enumerate all the stable return values from hooks, i.e., the ones that share the lifecycle of their component.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie mit der Seite „Lifecycle of Reactive Effects“ und der aktuellen Dokumentation zu useReducer und vergleichen Sie sie anschließend mit den im Issue zitierten Stabilitätsdetails. Verfolgen Sie, wo Garantien für von Hooks zurückgegebene Werte dokumentiert sind, und aktualisieren Sie die relevante Dokumentation, sodass die Stabilität von dispatch und die vorgesehenen stabilen Hook-Werte explizit und konsistent sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, react
- Bereich
- documentation
- Issue-Typ
- Dokumentation
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100