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](https://github.com/facebook/react/issues/7942) before submitting a PR.
/**
 * Copyright 2013-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 *
 * @providesModule ReactFiberCommitWork
 * @flow
 */
'use strict';
import type { Fiber } from 'ReactFiber';
import type { FiberRoot } from 'ReactFiberRoot';
import type { HostConfig } from 'ReactFiberReconciler';
var ReactTypeOfWork = require('ReactTypeOfWork');
var {
  ClassComponent,
  HostContainer,
  HostComponent,
  HostText,
} = ReactTypeOfWork;
var { callCallbacks } = require('ReactFiberUpdateQueue');