From 298ec6ca5de1a14cd70152364ecead5c8fcb04a5 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Mon, 7 Jul 2025 09:29:57 -0700 Subject: [PATCH] Deprecate ShadowNode::ListOfWeak and replace with std::vector> (#52401) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52401 changelog: [internal] - Mark ShadowNode::ListOfWeak as deprecated with appropriate deprecation message - Replace all usages of ShadowNode::ListOfWeak with std::vector> - Updated primitives.h and ReactNativeCPP.api to use the explicit type instead of the alias This change continues the effort to remove type aliases in favor of explicit standard library types for better code clarity and maintainability. Reviewed By: christophpurrer Differential Revision: D77652083 fbshipit-source-id: 79cad019e039c19f661346604ff49a44a4af7a79 --- .../ReactCommon/react/renderer/core/ShadowNode.h | 8 ++++++-- .../ReactCommon/react/renderer/uimanager/primitives.h | 3 ++- private/cxx-public-api/ReactNativeCPP.api | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/core/ShadowNode.h b/packages/react-native/ReactCommon/react/renderer/core/ShadowNode.h index eb7fd0cb112..445bb9d9b07 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/ShadowNode.h +++ b/packages/react-native/ReactCommon/react/renderer/core/ShadowNode.h @@ -45,12 +45,16 @@ class ShadowNode : public Sealable, using ListOfShared [[deprecated( "Use std::vector> instead")]] = std::vector>; - using ListOfWeak = std::vector>; + // TODO(T223558094): delete this in the next version. + using ListOfWeak [[deprecated( + "Use std::vector> instead")]] = + std::vector>; using SharedListOfShared = std::shared_ptr>>; using UnsharedListOfShared = std::shared_ptr>>; - using UnsharedListOfWeak = std::shared_ptr; + using UnsharedListOfWeak = + std::shared_ptr>>; using AncestorList = std::vector /* parentNode */, diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/primitives.h b/packages/react-native/ReactCommon/react/renderer/uimanager/primitives.h index af0da029f10..70cb2a1cbcb 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/primitives.h +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/primitives.h @@ -112,7 +112,8 @@ inline static ShadowNode::UnsharedListOfWeak weakShadowNodeListFromValue( jsi::Runtime& runtime, const jsi::Value& value) { auto shadowNodeList = shadowNodeListFromValue(runtime, value); - auto weakShadowNodeList = std::make_shared(); + auto weakShadowNodeList = + std::make_shared>>(); for (const auto& shadowNode : *shadowNodeList) { weakShadowNodeList->push_back(shadowNode); } diff --git a/private/cxx-public-api/ReactNativeCPP.api b/private/cxx-public-api/ReactNativeCPP.api index 8c2f51b8e1b..d52206efcce 100644 --- a/private/cxx-public-api/ReactNativeCPP.api +++ b/private/cxx-public-api/ReactNativeCPP.api @@ -37938,7 +37938,7 @@ inline static ShadowNode::UnsharedListOfWeak weakShadowNodeListFromValue( jsi::Runtime& runtime, const jsi::Value& value) { auto shadowNodeList = shadowNodeListFromValue(runtime, value); - auto weakShadowNodeList = std::make_shared(); + auto weakShadowNodeList = std::make_shared>>(); for (const auto& shadowNode : *shadowNodeList) { weakShadowNodeList->push_back(shadowNode); }