mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-26 13:35:32 +08:00
Add back old drawer behavior with unmountInactiveRoutes config
This commit is contained in:
@@ -5,12 +5,21 @@ import { createAppContainer } from '@react-navigation/native';
|
||||
// eslint-disable-next-line import/named
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import { List, Divider } from 'react-native-paper';
|
||||
import SimpleDrawer from './src/SimpleDrawer';
|
||||
import { SimpleDrawer, SimpleDrawerUnmountInactive } from './src/SimpleDrawer';
|
||||
import StyledDrawer from './src/StyledDrawer';
|
||||
import GestureInteraction from './src/GestureInteraction';
|
||||
|
||||
const data = [
|
||||
{ component: SimpleDrawer, title: 'Simple', routeName: 'SimpleDrawer' },
|
||||
{
|
||||
component: SimpleDrawer,
|
||||
title: 'Simple - persistent routes like tabs',
|
||||
routeName: 'SimpleDrawer',
|
||||
},
|
||||
{
|
||||
component: SimpleDrawerUnmountInactive,
|
||||
title: 'Simple - unmount inactive routes',
|
||||
routeName: 'SimpleDrawerUnmountInactive',
|
||||
},
|
||||
{ component: StyledDrawer, title: 'Styled', routeName: 'StyledDrawer' },
|
||||
{
|
||||
component: GestureInteraction,
|
||||
|
||||
@@ -122,27 +122,35 @@ DraftsStack.navigationOptions = {
|
||||
),
|
||||
};
|
||||
|
||||
const DrawerExample = createDrawerNavigator(
|
||||
{
|
||||
Inbox: {
|
||||
path: '/',
|
||||
screen: InboxStack,
|
||||
function createDrawerExample(options = {}) {
|
||||
let DrawerExample = createDrawerNavigator(
|
||||
{
|
||||
Inbox: {
|
||||
path: '/',
|
||||
screen: InboxStack,
|
||||
},
|
||||
Drafts: {
|
||||
path: '/sent',
|
||||
screen: DraftsStack,
|
||||
},
|
||||
},
|
||||
Drafts: {
|
||||
path: '/sent',
|
||||
screen: DraftsStack,
|
||||
},
|
||||
},
|
||||
{
|
||||
initialRouteName: 'Drafts',
|
||||
drawerWidth: 210,
|
||||
navigationOptions: {
|
||||
header: null,
|
||||
},
|
||||
contentOptions: {
|
||||
activeTintColor: '#e91e63',
|
||||
},
|
||||
}
|
||||
);
|
||||
{
|
||||
initialRouteName: 'Drafts',
|
||||
drawerWidth: 210,
|
||||
navigationOptions: {
|
||||
header: null,
|
||||
},
|
||||
contentOptions: {
|
||||
activeTintColor: '#e91e63',
|
||||
},
|
||||
...options,
|
||||
}
|
||||
);
|
||||
|
||||
export default DrawerExample;
|
||||
return DrawerExample;
|
||||
}
|
||||
|
||||
export const SimpleDrawer = createDrawerExample();
|
||||
export const SimpleDrawerUnmountInactive = createDrawerExample({
|
||||
unmountInactiveRoutes: true,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user