diff --git a/Examples/UIExplorer/UIExplorerNavigationReducer.js b/Examples/UIExplorer/UIExplorerNavigationReducer.js index 77a09adf4..854e5b36e 100644 --- a/Examples/UIExplorer/UIExplorerNavigationReducer.js +++ b/Examples/UIExplorer/UIExplorerNavigationReducer.js @@ -36,8 +36,12 @@ export type UIExplorerNavigationState = { }; const UIExplorerStackReducer = StackReducer({ - getPushedReducerForAction: (action) => { + getPushedReducerForAction: (action, lastState) => { if (action.type === 'UIExplorerExampleAction' && UIExplorerList.Modules[action.openExample]) { + if (lastState.children.find(child => child.key === action.openExample)) { + // The example is already open, we should avoid pushing examples twice + return null; + } return (state) => state || {key: action.openExample}; } return null; diff --git a/Libraries/NavigationExperimental/Reducer/NavigationStackReducer.js b/Libraries/NavigationExperimental/Reducer/NavigationStackReducer.js index f27df30fb..520d788b8 100644 --- a/Libraries/NavigationExperimental/Reducer/NavigationStackReducer.js +++ b/Libraries/NavigationExperimental/Reducer/NavigationStackReducer.js @@ -29,7 +29,7 @@ export type NavigationStackReducerAction = BackAction | { export type ReducerForStateHandler = (state: NavigationState) => NavigationReducer; -export type PushedReducerForActionHandler = (action: any) => ?NavigationReducer; +export type PushedReducerForActionHandler = (action: any, lastState: NavigationParentState) => ?NavigationReducer; export type StackReducerConfig = { /* @@ -93,7 +93,7 @@ function NavigationStackReducer({initialState, getReducerForState, getPushedRedu }; } - const subReducerToPush = getPushedReducerForAction(action); + const subReducerToPush = getPushedReducerForAction(action, lastParentState); if (subReducerToPush) { return NavigationStateUtils.push( lastParentState,