Skip to content

Commit

Permalink
fix: block GH interactions in Native Stack example (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
osdnk committed Oct 15, 2019
1 parent 9d9fe31 commit 386d1c0
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion packages/example/src/Screens/NativeStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { View, StyleSheet } from 'react-native';
import { Button } from 'react-native-paper';
// eslint-disable-next-line import/no-unresolved
import { useScreens } from 'react-native-screens';
import { RouteProp, ParamListBase } from '@react-navigation/core';
import {
RouteProp,
ParamListBase,
useFocusEffect,
} from '@react-navigation/core';
import { DrawerNavigationProp } from '@react-navigation/drawer';
import { StackNavigationProp } from '@react-navigation/stack';
import {
createNativeStackNavigator,
Expand Down Expand Up @@ -84,6 +89,22 @@ export default function NativeStackScreen({ navigation }: Props) {
headerShown: false,
});

useFocusEffect(
React.useCallback(() => {
const drawer = navigation.dangerouslyGetParent() as DrawerNavigationProp<
ParamListBase
>;

navigation.setOptions({ gestureEnabled: false });
drawer.setOptions({ drawerLockMode: 'locked-closed' });

return () => {
navigation.setOptions({ gestureEnabled: true });
drawer.setOptions({ drawerLockMode: 'unlocked' });
};
}, [navigation])
);

return (
<NativeStack.Navigator>
<NativeStack.Screen
Expand Down

0 comments on commit 386d1c0

Please sign in to comment.