How to Pass Parameters to screen in StackNavigator?

后端 未结 6 1373
抹茶落季
抹茶落季 2020-12-13 05:46

My React Native code:

import React, { Component } from \'react\';
import { AppRegistry, ActivityIndicator, StyleSheet, ListView, 
  Text, Button, TouchableH         


        
6条回答
  •  不思量自难忘°
    2020-12-13 06:26

    In your first page, say CountriesList

    const CountriesList = ({ navigation }) => {
    
    /* Function to navigate to 2nd screen */
      const viewCountry = (country) => {
        navigation.navigate('ListItemPageRoute', { name: country.country_name });
      };
    }
    

    For your second page name, say ListItemPageRoute

    const ListItemPageRoute = (props) => {
    
    return (
        
             { props.route.params.name } 
        
      );
    };
    

    'Props.route' Object will have the list of all parameters you would like to pass from one screen to another.

提交回复
热议问题