注意:此查询适用于 react-navigation 5。
在react导航 4 中,我们可以在导航时将函数作为参数传递,但在react导航 5 中,它会引发有关序列化参数的警告。
基本上,我想要做的是,从父屏幕导航到子屏幕,获取新值并更新父屏幕的状态。
以下是我目前正在实施的方式:
父屏幕
_onSelectCountry = (data) => {
    this.setState(data);
};
.
.
.
<TouchableOpacity
    style={ styles.countrySelector }
    activeOpacity={ 0.7 }
    onPress={ () => Navigation.navigate("CountrySelect",
        {
             onSelect: this._onSelectCountry,
             countryCode: this.state.country_code,
        })
    }
>
.
.
.
</TouchableOpacity> 
儿童屏幕
_onPress = (country, country_code, calling_code) => {
    const { navigation, route } = this.props;
    navigation.goBack();
    route.params.onSelect({
        country_name: country,
        country_code: country_code,
        calling_code: calling_code
    });
};