From c0375b8dadaafc0e0c11bbe676a61c44ac9fab1d Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Wed, 29 Nov 2023 10:28:53 -0800 Subject: [PATCH] CxxReactPackage: Make initHybrid static (#41681) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41681 ## Rationale Make initHybrid static. So that the derived class can initialize the C++ part with constructor arguments. **Note:** This diff just applies the fix from D51550623. into CxxReactPackage. Changelog: [Internal] Reviewed By: christophpurrer Differential Revision: D51642219 fbshipit-source-id: 095e452e03848379288af960969789aa5e9c0542 --- .../react/runtime/cxxreactpackage/CxxReactPackage.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/cxxreactpackage/CxxReactPackage.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/cxxreactpackage/CxxReactPackage.kt index bba110e72361fd..12cfb9ac017292 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/cxxreactpackage/CxxReactPackage.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/cxxreactpackage/CxxReactPackage.kt @@ -17,12 +17,10 @@ import com.facebook.soloader.SoLoader @UnstableReactNativeAPI() abstract class CxxReactPackage { - @DoNotStrip @Suppress("NoHungarianNotation") private var mHybridData: HybridData? = initHybrid() + @DoNotStrip @Suppress("NoHungarianNotation") private var mHybridData: HybridData? - protected abstract fun initHybrid(): HybridData - - protected constructor() { - mHybridData = initHybrid() + protected constructor(hybridData: HybridData?) { + mHybridData = hybridData } companion object {