Order of life cycle method calls with error boundaries is unexpected
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 11.8k
- Forks
- 7.9k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 11
Description
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file, test, or entry point is named. Start by locating the React documentation covering componentDidMount, componentDidUpdate, componentDidCatch, and error boundaries, then verify the reported lifecycle ordering. Done means the expected behavior and a supported way to distinguish successful and failed rendering are clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100