React: [Fiber] Handle errors in callbacks

Created on 8 Nov 2016  路  6Comments  路  Source: facebook/react

During the commit phase (when updates are flushed to the DOM), errors that are thrown inside componentDidMount and componentDidUpdate are trapped so they can be handled later, after the tree has been committed.

An error thrown in a setState callback should be trapped and handled the same way.

Here's the relevant section of code: https://github.com/facebook/react/blob/master/src/renderers/shared/fiber/ReactFiberCommitWork.js#L302-L330

callCallbacks calls all the setState callbacks that are part of the update queue (a linked list of updates). If any of those callbacks throw an error, we should catch the error and continue calling the rest of the callbacks.

This is a good first issue for someone interested in contributing to React/React Fiber. Please read Fiber Principles: Contributing to Fiber before submitting a PR.

starter

Most helpful comment

I'll have a look at it either. Not afraid to work really hard on it and someone else doing it instead (also known as learning awesome stuff :) )

All 6 comments

If anyone wants to claim this, please comment here so everyone knows.

I wouldn't mind giving it a go, but please don't let that stop anyone else from trying either?

@peterp Sure! Just don't want people to work really hard on a PR only to find at the end that someone else has already submitted a fix. Please comment here if/when you're willing to commit to finishing a PR :)

I'll have a look at it either. Not afraid to work really hard on it and someone else doing it instead (also known as learning awesome stuff :) )

Would love to take a look :)

I can take a look too. Not sure I will ve able to do something but it may helps me to undestand anyway.

Was this page helpful?
0 / 5 - 0 ratings