mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add ReactPackage.getModule method (#39336)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/39336 We are introducing the new getModule method into the ReactPackage interface following the "Registration of Native Modules" design This method defaults to true with the goal to avoid compatibility breakage changelog: [Android][Changed] Introducing getModule method into ReactPackage interface, defaulting to null. This method will be used in the Stable API of React Native Reviewed By: cortinico Differential Revision: D48992720 fbshipit-source-id: 4ecc93bc84daa8903a4d9a1cf6ced60adb78f153
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a6708247e1
commit
da8616ec69
@@ -14,6 +14,7 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.uimanager.UIManagerModule;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Main interface for providing additional capabilities to the catalyst framework by couple of
|
||||
@@ -44,4 +45,16 @@ public interface ReactPackage {
|
||||
/** @return a list of view managers that should be registered with {@link UIManagerModule} */
|
||||
@NonNull
|
||||
List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext);
|
||||
|
||||
/**
|
||||
* Given a module name, it returns an instance of {@link NativeModule} for the name
|
||||
*
|
||||
* @param name name of the Native Module
|
||||
* @param reactContext {@link ReactApplicationContext} context for this
|
||||
*/
|
||||
@Nullable
|
||||
default NativeModule getModule(
|
||||
@NonNull String name, @NonNull ReactApplicationContext reactContext) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -7,6 +7,7 @@
|
||||
|
||||
package com.facebook.react;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.bridge.ModuleHolder;
|
||||
import com.facebook.react.bridge.ModuleSpec;
|
||||
@@ -41,8 +42,9 @@ public abstract class TurboReactPackage implements ReactPackage {
|
||||
* @param name name of the Native Module
|
||||
* @param reactContext {@link ReactApplicationContext} context for this
|
||||
*/
|
||||
@Override
|
||||
public abstract @Nullable NativeModule getModule(
|
||||
String name, final ReactApplicationContext reactContext);
|
||||
@NonNull String name, @NonNull ReactApplicationContext reactContext);
|
||||
|
||||
/**
|
||||
* This is a temporary method till we implement TurboModules. Once we implement TurboModules, we
|
||||
|
||||
Reference in New Issue
Block a user