Fix navigation in UIExplorer. Use current index instead of fixed valu…

Summary:Motivation: After second navigation event in UIExplorer, content in main page always stayed the same.
Fix: For second and future navigation events use stack.index to retrieve state from stack.children.
Closes https://github.com/facebook/react-native/pull/6312

Differential Revision: D3018119

Pulled By: andreicoman11

fb-gh-sync-id: 4c502c42a0cb7b240e558515fb8fd766d6e1f856
shipit-source-id: 4c502c42a0cb7b240e558515fb8fd766d6e1f856
This commit is contained in:
Michal Kulinski 2016-03-07 03:03:41 -08:00 committed by Facebook Github Bot 1
parent 7ff938f8df
commit 11594b8531
1 changed files with 4 additions and 2 deletions

View File

@ -105,8 +105,10 @@ class UIExplorerApp extends React.Component {
}
const {stack} = navigationState;
const title = UIExplorerStateTitleMap(stack.children[stack.index]);
if (stack && stack.children[1]) {
const {key} = stack.children[1];
const index = stack.children.length <= 1 ? 1 : stack.index;
if (stack && stack.children[index]) {
const {key} = stack.children[index];
const ExampleModule = UIExplorerList.Modules[key];
const ExampleComponent = UIExplorerExampleList.makeRenderable(ExampleModule);
return (