mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-04 09:27:53 +08:00
make main component name nullable
Summary: Sometimes the main component name is not known at activity construction time and depends on e.g. reading shared preferences. To support this use case, make `(Fragment)ReactActivity#getMainComponentName()` nullable and return `null` by default. In this case, the app will not be loaded in `onCreate` by default and the user has to call `loadApp` manually once the component name is known. Reviewed By: andreicoman11 Differential Revision: D3722517 fbshipit-source-id: 062eed158798606e4160f1c142b23fd98ca618c8
This commit is contained in:
committed by
Facebook Github Bot 8
parent
2f78852411
commit
af2bb20893
@@ -9,6 +9,8 @@
|
||||
|
||||
package com.facebook.react;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
@@ -36,7 +38,9 @@ public abstract class ReactFragmentActivity extends FragmentActivity implements
|
||||
* This is used to schedule rendering of the component.
|
||||
* e.g. "MoviesApp"
|
||||
*/
|
||||
protected abstract String getMainComponentName();
|
||||
protected @Nullable String getMainComponentName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called at construction time, override if you have a custom delegate implementation.
|
||||
@@ -121,4 +125,8 @@ public abstract class ReactFragmentActivity extends FragmentActivity implements
|
||||
protected final ReactInstanceManager getReactInstanceManager() {
|
||||
return mDelegate.getReactInstanceManager();
|
||||
}
|
||||
|
||||
protected final void loadApp(String appKey) {
|
||||
mDelegate.loadApp(appKey);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user