Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private handleGoBack = ({ route }: { route: Route }) => {
const { state, navigation } = this.props;
// This event will trigger when a gesture ends
// We need to perform the transition before removing the route completely
navigation.dispatch({
...StackActions.pop(),
source: route.key,
target: state.key,
});
};
requestAnimationFrame(() => {
if (state.index > 0 && isFocused && !e.defaultPrevented) {
// When user taps on already focused tab and we're inside the tab,
// reset the stack to replicate native behaviour
navigation.dispatch({
...StackActions.popToTop(),
target: state.key,
});
}
});
}),
requestAnimationFrame(() => {
if (state.index > 0 && isFocused && !e.defaultPrevented) {
// When user taps on already focused tab and we're inside the tab,
// reset the stack to replicate native behaviour
navigation.dispatch({
...StackActions.popToTop(),
target: state.key,
});
}
});
}),
const handleDrawerClose = () => {
navigation.dispatch({
...DrawerActions.closeDrawer(),
target: state.key,
});
navigation.emit({ type: 'drawerClose' });
};
const handleDrawerOpen = () => {
navigation.dispatch({
...DrawerActions.openDrawer(),
target: state.key,
});
navigation.emit({ type: 'drawerOpen' });
};
export function pop({ n = 1 }: { n: number }): StackActionType {
return StackActions.pop(n);
}
? () =>
navigation.dispatch({
...StackActions.pop(),
source: scene.route.key,
})
: undefined
onDismissed={() => {
navigation.dispatch({
...StackActions.pop(),
source: route.key,
target: state.key,
});
}}
>
onPress={() => {
navigation.dispatch({
...(focused
? DrawerActions.closeDrawer()
: CommonActions.navigate(route.name)),
target: state.key,
});
}}
/>
private handleItemPress = ({
route,
focused,
}: {
route: Route;
focused: boolean;
}) => {
const { state, navigation } = this.props;
navigation.dispatch({
...(focused
? DrawerActions.closeDrawer()
: CommonActions.navigate(route.name)),
target: state.key,
});
};