From 78df536c78b38ff4bfed4653eaf593a260aa3f7d Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Thu, 28 Jan 2021 04:40:27 -0800 Subject: [PATCH] Call updateMountedFlag in ShadowTree::tryCommit only if commit will go to native Summary: Changelog: [internal] `updateMountedFlag` needs to be called only when new revision will be mounted. In case a commit is throttled, this wasn't the case. Therefore, moving cancellation of commit so it happens before `updateMountedFlag`. We already cancel commits on that place so it should be safe. Reviewed By: shergin Differential Revision: D26049262 fbshipit-source-id: e0ecdd2d8f0cdb09d0c0a07ad3931ce77bcf03cf --- ReactCommon/react/renderer/mounting/ShadowTree.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ReactCommon/react/renderer/mounting/ShadowTree.cpp b/ReactCommon/react/renderer/mounting/ShadowTree.cpp index 88e3f3a8b3b..3a56b4631cc 100644 --- a/ReactCommon/react/renderer/mounting/ShadowTree.cpp +++ b/ReactCommon/react/renderer/mounting/ShadowTree.cpp @@ -371,7 +371,8 @@ CommitStatus ShadowTree::tryCommit( newRootShadowNode = delegate_.shadowTreeWillCommit( *this, oldRootShadowNode, newRootShadowNode); - if (!newRootShadowNode) { + if (!newRootShadowNode || + (commitOptions.shouldCancel && commitOptions.shouldCancel())) { return CommitStatus::Cancelled; } @@ -392,10 +393,6 @@ CommitStatus ShadowTree::tryCommit( currentRevision_ = newRevision; } - if (commitOptions.shouldCancel && commitOptions.shouldCancel()) { - return CommitStatus::Cancelled; - } - emitLayoutEvents(affectedLayoutableNodes); if (commitMode == CommitMode::Normal) {