Deprecate ShadowNode::ListOfWeak and replace with std::vector<std::weak_ptr<const ShadowNode>> (#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<std::weak_ptr<const ShadowNode>>
- 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
This commit is contained in:
Samuel Susla
2025-07-07 09:29:57 -07:00
committed by Facebook GitHub Bot
parent c1200718a0
commit 298ec6ca5d
3 changed files with 9 additions and 4 deletions
@@ -45,12 +45,16 @@ class ShadowNode : public Sealable,
using ListOfShared [[deprecated(
"Use std::vector<std::shared_ptr<const ShadowNode>> instead")]] =
std::vector<std::shared_ptr<const ShadowNode>>;
using ListOfWeak = std::vector<std::weak_ptr<const ShadowNode>>;
// TODO(T223558094): delete this in the next version.
using ListOfWeak [[deprecated(
"Use std::vector<std::weak_ptr<const ShadowNode>> instead")]] =
std::vector<std::weak_ptr<const ShadowNode>>;
using SharedListOfShared =
std::shared_ptr<const std::vector<std::shared_ptr<const ShadowNode>>>;
using UnsharedListOfShared =
std::shared_ptr<std::vector<std::shared_ptr<const ShadowNode>>>;
using UnsharedListOfWeak = std::shared_ptr<ListOfWeak>;
using UnsharedListOfWeak =
std::shared_ptr<std::vector<std::weak_ptr<const ShadowNode>>>;
using AncestorList = std::vector<std::pair<
std::reference_wrapper<const ShadowNode> /* parentNode */,
@@ -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<ShadowNode::ListOfWeak>();
auto weakShadowNodeList =
std::make_shared<std::vector<std::weak_ptr<const ShadowNode>>>();
for (const auto& shadowNode : *shadowNodeList) {
weakShadowNodeList->push_back(shadowNode);
}
+1 -1
View File
@@ -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<ShadowNode::ListOfWeak>();
auto weakShadowNodeList = std::make_shared<std::vector<std::weak_ptr<const ShadowNode>>>();
for (const auto& shadowNode : *shadowNodeList) {
weakShadowNodeList->push_back(shadowNode);
}