From fe887173ee5a30fb913247fa48466d09d7427d41 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 11 Dec 2020 14:05:19 -0800 Subject: [PATCH] Fix clone of props for legacy interop component Summary: Changelog: [internal] Cloning of `LegacyViewManagerInteropViewProps` causes loss of `sourceProps.otherProps` if the cloning happens before shadow node is mounted. This was happening in WebView and callback `onLoadEnd` was dropped because of this. Reviewed By: JoshuaGross Differential Revision: D25474581 fbshipit-source-id: 74d7c5cd32b7318bb99306c82bc8b5e5eab63db2 --- .../LegacyViewManagerInteropViewProps.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.cpp b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.cpp index 891c0e0aecc..5d123f49f4d 100644 --- a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.cpp +++ b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.cpp @@ -10,10 +10,20 @@ namespace facebook { namespace react { +static folly::dynamic recursiveMerge( + folly::dynamic const &lhs, + folly::dynamic const &rhs) { + auto copy = lhs; + copy.merge_patch(rhs); + return copy; +} + LegacyViewManagerInteropViewProps::LegacyViewManagerInteropViewProps( const LegacyViewManagerInteropViewProps &sourceProps, const RawProps &rawProps) - : ViewProps(sourceProps, rawProps), otherProps((folly::dynamic)rawProps) {} + : ViewProps(sourceProps, rawProps), + otherProps( + recursiveMerge(sourceProps.otherProps, (folly::dynamic)rawProps)) {} } // namespace react } // namespace facebook