Skip to content

Commit 298ec6c

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
Deprecate ShadowNode::ListOfWeak and replace with std::vector<std::weak_ptr<const ShadowNode>> (#52401)
Summary: Pull Request resolved: #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
1 parent c120071 commit 298ec6c

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

packages/react-native/ReactCommon/react/renderer/core/ShadowNode.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@ class ShadowNode : public Sealable,
4545
using ListOfShared [[deprecated(
4646
"Use std::vector<std::shared_ptr<const ShadowNode>> instead")]] =
4747
std::vector<std::shared_ptr<const ShadowNode>>;
48-
using ListOfWeak = std::vector<std::weak_ptr<const ShadowNode>>;
48+
// TODO(T223558094): delete this in the next version.
49+
using ListOfWeak [[deprecated(
50+
"Use std::vector<std::weak_ptr<const ShadowNode>> instead")]] =
51+
std::vector<std::weak_ptr<const ShadowNode>>;
4952
using SharedListOfShared =
5053
std::shared_ptr<const std::vector<std::shared_ptr<const ShadowNode>>>;
5154
using UnsharedListOfShared =
5255
std::shared_ptr<std::vector<std::shared_ptr<const ShadowNode>>>;
53-
using UnsharedListOfWeak = std::shared_ptr<ListOfWeak>;
56+
using UnsharedListOfWeak =
57+
std::shared_ptr<std::vector<std::weak_ptr<const ShadowNode>>>;
5458

5559
using AncestorList = std::vector<std::pair<
5660
std::reference_wrapper<const ShadowNode> /* parentNode */,

packages/react-native/ReactCommon/react/renderer/uimanager/primitives.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ inline static ShadowNode::UnsharedListOfWeak weakShadowNodeListFromValue(
112112
jsi::Runtime& runtime,
113113
const jsi::Value& value) {
114114
auto shadowNodeList = shadowNodeListFromValue(runtime, value);
115-
auto weakShadowNodeList = std::make_shared<ShadowNode::ListOfWeak>();
115+
auto weakShadowNodeList =
116+
std::make_shared<std::vector<std::weak_ptr<const ShadowNode>>>();
116117
for (const auto& shadowNode : *shadowNodeList) {
117118
weakShadowNodeList->push_back(shadowNode);
118119
}

private/cxx-public-api/ReactNativeCPP.api

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37938,7 +37938,7 @@ inline static ShadowNode::UnsharedListOfWeak weakShadowNodeListFromValue(
3793837938
jsi::Runtime& runtime,
3793937939
const jsi::Value& value) {
3794037940
auto shadowNodeList = shadowNodeListFromValue(runtime, value);
37941-
auto weakShadowNodeList = std::make_shared<ShadowNode::ListOfWeak>();
37941+
auto weakShadowNodeList = std::make_shared<std::vector<std::weak_ptr<const ShadowNode>>>();
3794237942
for (const auto& shadowNode : *shadowNodeList) {
3794337943
weakShadowNodeList->push_back(shadowNode);
3794437944
}

0 commit comments

Comments
 (0)