mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add NativeLogBox module on Android
Summary: This diff adds a NativeLogBox module implementation on Android to manage rendering LogBox the way we render RedBox, except rendering a React Native component instead of a native view. The strategy here is: - initialize: will create a React rootview and render it. - show: will add the rootview to a dialog and display the dialog. - hide: will remove the rootview from it's parent, dismiss the dialog, and release the reference to the activity to prevent leaks. Most of this is copied from the way RedBox works, the difference here is that we eagerly initialize the rootview with the `initialize` function so that it's warm by the time the dialog needs to render. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D18768517 fbshipit-source-id: 2510d6c186ccf73153ef9372c736c9e0c71bbc7d
This commit is contained in:
committed by
Facebook Github Bot
parent
6b22a4e802
commit
e272089524
@@ -304,6 +304,27 @@ public class ReactInstanceManager {
|
||||
public JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
|
||||
return ReactInstanceManager.this.getJSExecutorFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable View createRootView(String appKey) {
|
||||
Activity currentActivity = getCurrentActivity();
|
||||
if (currentActivity != null) {
|
||||
ReactRootView rootView = new ReactRootView(currentActivity);
|
||||
|
||||
rootView.startReactApplication(ReactInstanceManager.this, appKey, null);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyRootView(View rootView) {
|
||||
if (rootView instanceof ReactRootView) {
|
||||
((ReactRootView) rootView).unmountReactApplication();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user