[fix] AppRegistry.getApplication shouldn't throw if missing options

Fix #899
This commit is contained in:
Nicolas Gallagher
2018-04-21 12:05:42 -07:00
parent 38affa9bae
commit c6e2b584af
3 changed files with 8 additions and 3 deletions

View File

@@ -22,6 +22,11 @@ describe('AppRegistry', () => {
ExecutionEnvironment.canUseDOM = canUseDOM;
});
test('does not throw when missing appParameters', () => {
AppRegistry.registerComponent('App', () => RootComponent);
expect(() => AppRegistry.getApplication('App')).not.toThrow();
});
test('returns "element" and "getStyleElement"', () => {
AppRegistry.registerComponent('App', () => RootComponent);

View File

@@ -58,7 +58,7 @@ export default class AppRegistry {
getApplication: appParameters =>
getApplication(
componentProviderInstrumentationHook(componentProvider),
appParameters.initialProps || emptyObject,
appParameters ? appParameters.initialProps : emptyObject,
wrapperComponentProvider && wrapperComponentProvider(appParameters)
),
run: appParameters =>
@@ -90,7 +90,7 @@ export default class AppRegistry {
return appKey;
}
static runApplication(appKey: string, appParameters?: Object): void {
static runApplication(appKey: string, appParameters: Object): void {
const isDevelopment = process.env.NODE_ENV !== 'production';
const params = { ...appParameters };
params.rootTag = `#${params.rootTag.id}`;

View File

@@ -93,7 +93,7 @@ const AppRegistryScreen = () => (
})`
}}
name="static runApplication"
typeInfo="(appKey: string, appParameters?: object) => void"
typeInfo="(appKey: string, appParameters: object) => void"
/>
<DocItem