skip to Main Content

When I use a component function as shown below, I’m able to access data passed through navigation.navigate("NavigateToScreen", {data: {}}) function in the following:

import { useNavigation } from '@react-navigation/native';

export default function ScreenName(props) {

   const data = props.route.params.data;

   const navigation = useNavigation();

}

How do I access data in target screen when receiving screen is as follows:

export default function ScreenName({ navigation }) {

   const data = //How do I receive props here

}

2

Answers


  1. You can access them through the route parameter:

    export default function ScreenName({ navigation, route }) {
    
       const { data } = route.params;
    
    }
    
    Login or Signup to reply.
  2. You can access them using the route parameter or check out the useRoute hook. Follow this link for a detailed explanation

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search