Image of founer

React Navigation CheatSheet

December 17, 2021


navigation.navigate('screenName', {someParam: param})

Can be accessed by the hook:

const route = useRoute();
const someParam = route.params?.someParam

When navigating down in a stack, the merge option can be applied to only override the params that have the same name.

navigation.navigate('screenName', {
	screen: 'innerScreen',
    merge: true,

// or

	screen: 'screenName',
	merge: true

If you want to navigate into another stack, and you want to have the navigation stack in a specifik order then you can navigate with the option initial.

navigation.navigate('screenName', {
	screen: 'innerScreen',
    initial: false,

This makes sure that navigation.goBack() navigates from innerScreen to screenName. If it is omitted, then the root screen of that stack will be innerScreen.