Skip to content

Commit

Permalink
add RedBoxHandler & UIImplementation to ReactNativeHost
Browse files Browse the repository at this point in the history
Summary: Allow overriding RedBoxHandler and UIImplementation in custom ReactNativeHost implementations.

Reviewed By: astreet

Differential Revision: D3655354

fbshipit-source-id: cc168613c75a8540e8a802ce33576b3b6a97749c
  • Loading branch information
foghina authored and Facebook Github Bot 1 committed Aug 8, 2016
1 parent deb0d60 commit baf5a5b
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import android.app.Application;

import com.facebook.infer.annotation.Assertions;
import com.facebook.react.devsupport.RedBoxHandler;
import com.facebook.react.uimanager.UIImplementationProvider;

/**
* Simple class that holds an instance of {@link ReactInstanceManager}. This can be used in your
Expand Down Expand Up @@ -64,6 +66,8 @@ protected ReactInstanceManager createReactInstanceManager() {
.setApplication(mApplication)
.setJSMainModuleName(getJSMainModuleName())
.setUseDeveloperSupport(getUseDeveloperSupport())
.setRedBoxHandler(getRedBoxHandler())
.setUIImplementationProvider(getUIImplementationProvider())
.setInitialLifecycleState(LifecycleState.BEFORE_CREATE);

for (ReactPackage reactPackage : getPackages()) {
Expand All @@ -76,10 +80,26 @@ protected ReactInstanceManager createReactInstanceManager() {
} else {
builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName()));
}

return builder.build();
}

/**
* Get the {@link RedBoxHandler} to send RedBox-related callbacks to.
*/
protected @Nullable RedBoxHandler getRedBoxHandler() {
return null;
}

/**
* Get the {@link UIImplementationProvider} to use. Override this method if you want to use a
* custom UI implementation.
*
* Note: this is very advanced functionality, in 99% of cases you don't need to override this.
*/
protected UIImplementationProvider getUIImplementationProvider() {
return new UIImplementationProvider();
}

/**
* Returns the name of the main module. Determines the URL used to fetch the JS bundle
* from the packager server. It is only used when dev support is enabled.
Expand Down

0 comments on commit baf5a5b

Please sign in to comment.