Skip to content

Commit

Permalink
Merge pull request #3634 from dklymenk/3559-fix-initial-route-after-r…
Browse files Browse the repository at this point in the history
…elogin

#3559 fix initial route after relogin
  • Loading branch information
luacmartins authored Jun 17, 2021
2 parents c5899fc + d322277 commit ce97fe2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/libs/Navigation/AppNavigator/MainDrawerNavigator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import _ from 'underscore';
import lodashGet from 'lodash/get';
import {createDrawerNavigator} from '@react-navigation/drawer';
import {withOnyx} from 'react-native-onyx';
Expand Down Expand Up @@ -41,8 +40,10 @@ const getInitialReportScreenParams = (reports) => {
};

const MainDrawerNavigator = (props) => {
// When there are no reports there's no point to render the empty navigator
if (_.size(props.reports) === 0) {
const initialParams = getInitialReportScreenParams(props.reports);

// Wait until reports are fetched and there is a reportID in initialParams
if (!initialParams.reportID) {
return <FullScreenLoadingIndicator visible />;
}

Expand All @@ -69,7 +70,7 @@ const MainDrawerNavigator = (props) => {
<Drawer.Screen
name={SCREENS.REPORT}
component={ReportScreen}
initialParams={getInitialReportScreenParams(props.reports)}
initialParams={initialParams}
/>
</Drawer.Navigator>
);
Expand Down

0 comments on commit ce97fe2

Please sign in to comment.