diff --git a/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp b/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp index 851231da950..46d2fc4c6cd 100644 --- a/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp +++ b/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp @@ -5,11 +5,14 @@ * LICENSE file in the root directory of this source tree. */ +#include + #include #include #include #include +#include #include #include @@ -102,6 +105,25 @@ static void testShadowNodeTreeLifeCycle( auto mutations = calculateShadowViewMutations( *currentRootNode, *nextRootNode, useFlattener); + // If using flattener: make sure that in a single frame, a DELETE for a view is not + // followed by a CREATE for the same view. + if (useFlattener) { + std::vector deletedTags{}; + for (auto const& mutation : mutations) { + if (mutation.type == ShadowViewMutation::Type::Delete) { + deletedTags.push_back(mutation.oldChildShadowView.tag); + } + } + for (auto const& mutation : mutations) { + if (mutation.type == ShadowViewMutation::Type::Create) { + if (std::find(deletedTags.begin(), deletedTags.end(), mutation.newChildShadowView.tag) != deletedTags.end()) { + LOG(ERROR) << "Deleted tag was recreated in mutations list: [" << mutation.newChildShadowView.tag << "]"; + FAIL(); + } + } + } + } + // Mutating the view tree. viewTree.mutate(mutations);