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.
For screens inside a Bottom Tab Navigator or Material Top Tab Navigator, tab actions are available as methods on the navigation object.
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('Home');
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Home!</Text>
<Button
onPress={() => {
navigation.jumpTo('Profile', { user: 'Satya' });
}}
>
Jump to Profile
</Button>
</View>
);
}
function HomeScreen() {
const navigation = useNavigation('Home');
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Home!</Text>
<Button
onPress={() => {
navigation.jumpTo('Profile', { user: 'Satya' });
}}
>
Jump to Profile
</Button>
</View>
);
}
It can also be used with navigation.dispatch:
import { TabActions } from '@react-navigation/native';
navigation.dispatch(TabActions.jumpTo('Profile', { user: 'Satya' }));