Passing parameters to routes using hooks

Viewed 817

I am trying to pass data in hooks from one tab to previous (both screens are in the TabNavigator) and using this official doc to send data to previous but due to some reason I am not getting any data in useEffect

At tabB

navigation.navigate('tabA', {rideStatus: 'start'});

at TabA I am trying to get this data like below

    export default function PamentOption<MapsProps>({ route, navigation }) {
      
   React.useEffect(() => {
    if (route.params?.rideStatus) {
        console.log('this is it')
    }
  }, [route.params?.rideStatus]);
}

it is going from one tab to another tab but can not get data

1 Answers

For me the problem was stack navigators for every tab
Please check that if you are using different stacks for different tabs if yes you can use single stack for all tabs or use nested tabs like in the official doc

Related