From 1d45b20b6c6ba66df0485cdb9be36463d96cf182 Mon Sep 17 00:00:00 2001 From: "Julio C. Rocha" Date: Wed, 15 Dec 2021 14:36:22 -0800 Subject: [PATCH] Set CxxModule instance before retrieving Method vector (#32719) Summary: Allows `CxxModule` objects to set their `instance_` member before `getMethods()` is invoked, allowing for the `Method` callbacks to capture a weak reference to `getInstance()` if needed. ## Changelog [General] [Fixed] - Set CxxModules' Instance before retrieving their Method vector. Pull Request resolved: https://github.com/facebook/react-native/pull/32719 Test Plan: Ensure this statement swap does not break any scenarios with existing CI validation. Reviewed By: JoshuaGross Differential Revision: D32955616 Pulled By: genkikondo fbshipit-source-id: fd7a23ca2c12c01882ff1600f5aef86b1fe4a984 --- ReactCommon/cxxreact/CxxNativeModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReactCommon/cxxreact/CxxNativeModule.cpp b/ReactCommon/cxxreact/CxxNativeModule.cpp index 0bcf13657ee..bab53966dca 100644 --- a/ReactCommon/cxxreact/CxxNativeModule.cpp +++ b/ReactCommon/cxxreact/CxxNativeModule.cpp @@ -244,8 +244,8 @@ void CxxNativeModule::lazyInit() { module_ = provider_(); provider_ = nullptr; if (module_) { - methods_ = module_->getMethods(); module_->setInstance(instance_); + methods_ = module_->getMethods(); } }