TabActions reference
TabActions
is an object containing methods for generating actions specific to tab-based navigators. Its methods expand upon the actions available in CommonActions
.
The following actions are supported:
jumpTo
The jumpTo
action can be used to jump to an existing route in the tab navigator.
name
- string - Name of the route to jump to.params
- object - Screen params to pass to the destination route.
- Static
- Dynamic
function HomeScreen() {
const navigation = useNavigation();
const jumpToAction = TabActions.jumpTo('Profile', { user: 'Satya' });
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Home!</Text>
<Button
onPress={() => {
navigation.dispatch(jumpToAction);
}}
>
Jump to Profile
</Button>
</View>
);
}
function HomeScreen() {
const navigation = useNavigation();
const jumpToAction = TabActions.jumpTo('Profile', { user: 'Satya' });
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Home!</Text>
<Button
onPress={() => {
navigation.dispatch(jumpToAction);
}}
>
Jump to Profile
</Button>
</View>
);
}