Skip to content

Commit 2439f90

Browse files
committed
fix: holds moduleProxy as a weak pointer
To avoid circular reference
1 parent 0af1503 commit 2439f90

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/react-native-reanimated/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ void ReanimatedMountHook::shadowTreeDidMount(
4545

4646
// Create callback to notify JavaScript about node removal decisions
4747
auto callback = [this](Tag tag, bool isFrozen) {
48-
if (moduleProxy_) {
49-
moduleProxy_->onNodeRemovalDecision(tag, isFrozen);
48+
auto moduleProxy = moduleProxy_.lock();
49+
if (moduleProxy) {
50+
moduleProxy->onNodeRemovalDecision(tag, isFrozen);
5051
}
5152
};
5253
propsRegistry_->handleNodeRemovals(*rootShadowNode, callback);

packages/react-native-reanimated/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ReanimatedMountHook : public UIManagerMountHook {
3535
private:
3636
const std::shared_ptr<PropsRegistry> propsRegistry_;
3737
const std::shared_ptr<UIManager> uiManager_;
38-
const std::shared_ptr<ReanimatedModuleProxy> moduleProxy_;
38+
const std::weak_ptr<ReanimatedModuleProxy> moduleProxy_;
3939
};
4040

4141
} // namespace reanimated

0 commit comments

Comments
 (0)