From a8fc20616fbe673cdc854d33450a772fb7f11cf1 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 28 Nov 2023 08:10:17 -0800 Subject: [PATCH] do not use ShadowNode::defaultSharedProps in UIManager::clone (#41667) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41667 changelog: [internal] I made a mistake during refactor in D51471667 where I removed the check if rawProps is nullptr. We must check if props are empty during `UIManager::clone`, leaving the check for `ConcreteComponentDescriptor::cloneProps` does not lead to the same result. There is a deeper problem here that needs to be analysed but this should resolve the lunch blocker. Reviewed By: javache Differential Revision: D51614396 fbshipit-source-id: 055694c4a71a914d8732a3632c50026cc24cbe7d --- .../react/renderer/uimanager/UIManager.cpp | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp index b83cc710b69..a0f667430a9 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp @@ -122,22 +122,24 @@ std::shared_ptr UIManager::cloneNode( auto& family = shadowNode.getFamily(); auto props = ShadowNodeFragment::propsPlaceholder(); - if (family.nativeProps_DEPRECATED != nullptr) { - // Values in `rawProps` patch (take precedence over) - // `nativeProps_DEPRECATED`. For example, if both `nativeProps_DEPRECATED` - // and `rawProps` contain key 'A'. Value from `rawProps` overrides what - // was previously in `nativeProps_DEPRECATED`. - family.nativeProps_DEPRECATED = - std::make_unique(mergeDynamicProps( - *family.nativeProps_DEPRECATED, (folly::dynamic)rawProps)); + if (!rawProps.isEmpty()) { + if (family.nativeProps_DEPRECATED != nullptr) { + // Values in `rawProps` patch (take precedence over) + // `nativeProps_DEPRECATED`. For example, if both `nativeProps_DEPRECATED` + // and `rawProps` contain key 'A'. Value from `rawProps` overrides what + // was previously in `nativeProps_DEPRECATED`. + family.nativeProps_DEPRECATED = + std::make_unique(mergeDynamicProps( + *family.nativeProps_DEPRECATED, (folly::dynamic)rawProps)); - props = componentDescriptor.cloneProps( - propsParserContext, - shadowNode.getProps(), - RawProps(*family.nativeProps_DEPRECATED)); - } else { - props = componentDescriptor.cloneProps( - propsParserContext, shadowNode.getProps(), std::move(rawProps)); + props = componentDescriptor.cloneProps( + propsParserContext, + shadowNode.getProps(), + RawProps(*family.nativeProps_DEPRECATED)); + } else { + props = componentDescriptor.cloneProps( + propsParserContext, shadowNode.getProps(), std::move(rawProps)); + } } auto clonedShadowNode = componentDescriptor.cloneShadowNode(