Fix UIExplorer for android getting in a broken state

Summary:
If you have a new example that you add to the UIExplorer, enter the example, but
then change the name of the example or remove it, the explorer enters a
completely broken state. It remembers the name of the last module entered and
keeps trying to enter it. Reloading, refreshing, nothing will work until you
completely reinstall the app.
This fixes this by not trying to render the current module if it doesn't exist.
It will simply skip it.

Reviewed By: yungsters

Differential Revision: D4475088

fbshipit-source-id: d4a530b235aa2712d663377e33fe65091163d262
This commit is contained in:
Andrei Coman 2017-01-29 04:09:25 -08:00 committed by Facebook Github Bot
parent c68195929b
commit 9f10b85e10

View File

@ -151,29 +151,31 @@ class UIExplorerApp extends React.Component {
if (stack && stack.routes[index]) {
const {key} = stack.routes[index];
const ExampleModule = UIExplorerList.Modules[key];
return (
<View style={styles.container}>
<ToolbarAndroid
logo={nativeImageSource({
android: 'launcher_icon',
width: 132,
height: 144
})}
navIcon={nativeImageSource({
android: 'ic_menu_black_24dp',
width: 48,
height: 48
})}
onIconClicked={() => this.drawer.openDrawer()}
style={styles.toolbar}
title={title}
/>
<UIExplorerExampleContainer
module={ExampleModule}
ref={(example) => { this._exampleRef = example; }}
/>
</View>
);
if (ExampleModule) {
return (
<View style={styles.container}>
<ToolbarAndroid
logo={nativeImageSource({
android: 'launcher_icon',
width: 132,
height: 144
})}
navIcon={nativeImageSource({
android: 'ic_menu_black_24dp',
width: 48,
height: 48
})}
onIconClicked={() => this.drawer.openDrawer()}
style={styles.toolbar}
title={title}
/>
<UIExplorerExampleContainer
module={ExampleModule}
ref={(example) => { this._exampleRef = example; }}
/>
</View>
);
}
}
return (
<View style={styles.container}>