Skip to content

Commit

Permalink
Fix passing down wrong overlay navigation state in OverlayNavigator (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
wsxyeah authored and mvanroon committed Feb 15, 2018
1 parent a7a2776 commit 9a20ae5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions dist/OverlayNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,26 @@ routes=state.routes;

var Component=routeConfigs[tabsConfig.initialRouteName].screen;
var initialIndex=0;
var routesMap={};
for(var i=0;i<routes.length;i++){
var route=routes[i];
if(route.routeName===tabsConfig.initialRouteName){
initialIndex=i;
}
routesMap[route.routeName]=route;
}
var initialRouteName=tabsConfig.initialRouteName||routes[initialIndex].routeName;
var overlays=[];
for(var _i=0;_i<tabsConfig.order.length;_i++){
var routeName=tabsConfig.order[_i];
if(initialRouteName!==routeName){
var Overlay=routeConfigs[routeName].screen;
overlays.push(_react2.default.createElement(Overlay,{key:routeName,navigation:{dispatch:dispatch,state:state},__source:{fileName:_jsxFileName,lineNumber:37}}));
overlays.push(_react2.default.createElement(Overlay,{key:routeName,navigation:{dispatch:dispatch,state:routesMap[routeName]},__source:{fileName:_jsxFileName,lineNumber:39}}));
}
}
var ContentComponent=tabsConfig.contentComponent||_reactNative.View;
return _react2.default.createElement(ContentComponent,{style:{flex:1},__source:{fileName:_jsxFileName,lineNumber:41}},
_react2.default.createElement(Component,{navigation:{dispatch:dispatch,state:routes[initialIndex]},__source:{fileName:_jsxFileName,lineNumber:42}}),
return _react2.default.createElement(ContentComponent,{style:{flex:1},__source:{fileName:_jsxFileName,lineNumber:43}},
_react2.default.createElement(Component,{navigation:{dispatch:dispatch,state:routes[initialIndex]},__source:{fileName:_jsxFileName,lineNumber:44}}),
overlays);

});
Expand Down
4 changes: 3 additions & 1 deletion src/OverlayNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@ const OverlayNavigator = (
// Figure out what to render based on the navigation state and the router:
const Component = routeConfigs[tabsConfig.initialRouteName].screen;
let initialIndex = 0;
const routesMap = {};
for (let i = 0; i < routes.length; i++) {
const route = routes[i];
if (route.routeName === tabsConfig.initialRouteName) {
initialIndex = i;
}
routesMap[route.routeName] = route;
}
const initialRouteName = tabsConfig.initialRouteName || routes[initialIndex].routeName;
const overlays = [];
for (let i = 0; i < tabsConfig.order.length; i++) {
const routeName = tabsConfig.order[i];
if (initialRouteName !== routeName) {
const Overlay = routeConfigs[routeName].screen;
overlays.push(<Overlay key={routeName} navigation={{ dispatch, state }} />);
overlays.push(<Overlay key={routeName} navigation={{ dispatch, state: routesMap[routeName] }} />);
}
}
const ContentComponent = tabsConfig.contentComponent || View;
Expand Down

0 comments on commit 9a20ae5

Please sign in to comment.