From 8fba7ebb5e874d001dc5c16eb4229054a2ef4812 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Tue, 19 Nov 2024 10:19:14 -0800 Subject: [PATCH] Mark ReactPackage#getModule as stable (#47676) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47676 `getModule` is used by all modern ReactPackage base-classes to allow lazy loading of specific module and should be considered stable at this point. Changelog: [Android][Added] Marked ReactPackage#getModule as stable. Reviewed By: mdvacca Differential Revision: D66127068 fbshipit-source-id: de447794435d267619430e3c0cbc65c6e1c614ba --- packages/react-native/ReactAndroid/api/ReactAndroid.api | 1 + .../src/main/java/com/facebook/react/ReactPackage.java | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index a55f39188d0..07b31c52d88 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -342,6 +342,7 @@ public abstract class com/facebook/react/ReactNativeHost { public abstract interface class com/facebook/react/ReactPackage { public abstract fun createNativeModules (Lcom/facebook/react/bridge/ReactApplicationContext;)Ljava/util/List; public abstract fun createViewManagers (Lcom/facebook/react/bridge/ReactApplicationContext;)Ljava/util/List; + public fun getModule (Ljava/lang/String;Lcom/facebook/react/bridge/ReactApplicationContext;)Lcom/facebook/react/bridge/NativeModule; } public abstract interface class com/facebook/react/ReactPackageLogger { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactPackage.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactPackage.java index 940e50c24e1..fd2d2b8e301 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactPackage.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactPackage.java @@ -12,7 +12,7 @@ import com.facebook.infer.annotation.Nullsafe; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.common.annotations.DeprecatedInNewArchitecture; -import com.facebook.react.common.annotations.UnstableReactNativeAPI; +import com.facebook.react.common.annotations.StableReactNativeAPI; import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewManager; import java.util.List; @@ -43,7 +43,7 @@ public interface ReactPackage { * is deprecated in the new Architecture of React Native. */ @NonNull - @DeprecatedInNewArchitecture + @DeprecatedInNewArchitecture(message = "Migrate to BaseReactPackage and implement getModule") List createNativeModules(@NonNull ReactApplicationContext reactContext); /** @@ -59,7 +59,7 @@ public interface ReactPackage { * @param reactContext {@link ReactApplicationContext} context for this */ @Nullable - @UnstableReactNativeAPI + @StableReactNativeAPI default NativeModule getModule( @NonNull String name, @NonNull ReactApplicationContext reactContext) { return null;