Skip to content

Commit

Permalink
refactor: Mount the Report Screen only when initial data is resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
kidroca committed Apr 27, 2021
1 parent d6596c5 commit 1591d76
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/libs/Navigation/AppNavigator/MainDrawerNavigator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import _ from 'underscore';
import {createDrawerNavigator} from '@react-navigation/drawer';
import {withOnyx} from 'react-native-onyx';

Expand All @@ -14,6 +15,7 @@ import compose from '../../compose';
// Screens
import SidebarScreen from '../../../pages/home/sidebar/SidebarScreen';
import ReportScreen from '../../../pages/home/ReportScreen';
import FullScreenLoadingIndicator from '../../../components/FullscreenLoadingIndicator';

const propTypes = {
// Initial report to be used if nothing else is specified by routing
Expand All @@ -23,7 +25,7 @@ const propTypes = {
};

const defaultProps = {
initialReportID: '',
initialReportID: null,
};

const Drawer = createDrawerNavigator();
Expand All @@ -39,16 +41,26 @@ const MainDrawerNavigator = props => (
sceneContainerStyle={styles.navigationSceneContainer}
edgeWidth={500}
drawerContent={() => <SidebarScreen />}
screenOptions={{
cardStyle: styles.navigationScreenCardStyle,
headerShown: false,
}}
>
<Drawer.Screen
name="Report"
component={ReportScreen}
initialParams={{reportID: props.initialReportID}}
options={{
cardStyle: styles.navigationScreenCardStyle,
headerShown: false,
}}
/>
{
_.isString(props.initialReportID)
? (
<Drawer.Screen
name="Report"
component={ReportScreen}
initialParams={{reportID: props.initialReportID}}
/>
)
: (
<Drawer.Screen name="loading">
{() => <FullScreenLoadingIndicator visible />}
</Drawer.Screen>
)
}
</Drawer.Navigator>
);

Expand Down

0 comments on commit 1591d76

Please sign in to comment.