Order of life cycle method calls with error boundaries is unexpected
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
I have a requirement for my app to track when a component has completed rendering and whether the render ended in success or failure. I expected to be able to use the componentDidMount/componentDidUpdate life cycle methods along with an error boundary's componentDidCatch method to handle both success and failure cases.
However, I am noticing that the order of the life cycle methods is not what I expect. When an exception is raised within a child component in the error boundary, the component's componentDidMount/componentDidUpdate method will get called first before componentDidCatch. So I can't simply use componentDidMount/componentDidUpdate to determine that my scenario ended in success.
Is this a bug? How would I go about achieving this scenario?
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
Keine Datei, kein Test und kein Einstiegspunkt ist angegeben. Beginne damit, die React-Dokumentation zu componentDidMount, componentDidUpdate, componentDidCatch und Error Boundaries zu finden, und überprüfe anschließend die gemeldete Reihenfolge des Lebenszyklus. Fertig ist die Aufgabe, wenn das erwartete Verhalten und eine unterstützte Möglichkeit zur Unterscheidung zwischen erfolgreichem und fehlgeschlagenem Rendering eindeutig dokumentiert sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, react
- Bereich
- documentation
- Issue-Typ
- Dokumentation
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100