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

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/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
This commit is contained in:
Julio C. Rocha
2021-12-15 14:37:37 -08:00
committed by Facebook GitHub Bot
parent 89faf0c9a8
commit 1d45b20b6c
+1 -1
View File
@@ -244,8 +244,8 @@ void CxxNativeModule::lazyInit() {
module_ = provider_();
provider_ = nullptr;
if (module_) {
methods_ = module_->getMethods();
module_->setInstance(instance_);
methods_ = module_->getMethods();
}
}