ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java
@UiThread
  @ThreadConfined(UI)
  private void dispatchMountItemsCleanup() {
    // Should we dispatch again? We do this up to 10 times. This is a magic number subject to
    // change. TODO T63181639: pick a better magic number.
    // Reentrance into dispatchMountItems can potentially happen a lot on Android in Fabric because
    // `updateState` from the
    // mounting layer causes mount items to be dispatched synchronously. We want to 1) make sure
    // we don't reenter in those cases, but 2) still execute those queued instructions
    // synchronously.
    // This is a pretty blunt tool, but we might not have better options since we really don't want
    // to execute anything out-of-order.
    mInDispatch = false;
    if (mShouldDispatchAgain) {
      mReDispatchCounter++;
      mShouldDispatchAgain = false;
      ReactSoftException.logSoftException(
          TAG,
          new ReactNoCrashSoftException(
              "Re-dispatched "
                  + mReDispatchCounter
                  + " times. This indicates setState (?) is likely being called too many times during mounting."));

      // If we reach this point, we just wait for the next UI tick to execute mount instructions.
      if (mReDispatchCounter < 10) {
        dispatchMountItems();
      }
    }
    mReDispatchCounter = 0;
  }
/** Should be called at the end of every dispatchMountItems call. */
Should be called at the end of every dispatchMountItems call.
Should be called at the end of every dispatchMountItems call .
@UiThread
  @ThreadConfined(UI)
  private void dispatchMountItemsCleanup() {
    mInDispatch = false;
    if (mShouldDispatchAgain) {
      mReDispatchCounter++;
      mShouldDispatchAgain = false;
      ReactSoftException.logSoftException(
          TAG,
          new ReactNoCrashSoftException(
              "Re-dispatched "
                  + mReDispatchCounter
                  + " times. This indicates setState (?) is likely being called too many times during mounting."));
      if (mReDispatchCounter < 10) {
        dispatchMountItems();
      }
    }
    mReDispatchCounter = 0;
  }
@ UiThread @ ThreadConfined ( UI ) private void dispatchMountItemsCleanup ( ) { mInDispatch = false ; if ( mShouldDispatchAgain ) { mReDispatchCounter ++ ; mShouldDispatchAgain = false ; ReactSoftException . logSoftException ( TAG , new ReactNoCrashSoftException ( "Re-dispatched " + mReDispatchCounter + " times. This indicates setState (?) is likely being called too many times during mounting." ) ) ; if ( mReDispatchCounter < 10 ) { dispatchMountItems ( ) ; } } mReDispatchCounter = 0 ; }
Should be called at the end of every dispatchMountItems call.
Should be called at the end of every dispatchMountItems call .
// Should we dispatch again? We do this up to 10 times. This is a magic number subject to // change. TODO T63181639: pick a better magic number. // Reentrance into dispatchMountItems can potentially happen a lot on Android in Fabric because // `updateState` from the // mounting layer causes mount items to be dispatched synchronously. We want to 1) make sure // we don't reenter in those cases, but 2) still execute those queued instructions // synchronously. // This is a pretty blunt tool, but we might not have better options since we really don't want // to execute anything out-of-order. // If we reach this point, we just wait for the next UI tick to execute mount instructions.