将参数从一个屏幕传递到另一个屏幕

时间:2020-07-01 00:40:13

标签: javascript react-native

您好,社区我想将参数从一个屏幕传递到另一个屏幕,我发现在对象上打印了一个错误,指出未定义。因此,我被敦促安装react-navigation!但是,总是会发生此错误

Body : 
{"originModulePath":"node_modules\\@react-navigation\\stack\\src\\views\\Stack\
\CardStack.tsx","targetModuleName":"../Screens"",""message":"Unable to resolve module`../
Screens from mode_modules\ @react-navigation\\stack\\src\views\Stack\CardStack.tsx:\n\nNone of these fils exist:\n *node_modules\\@reactnavigation\\stack\\src\\views\Screens

CreationDaret(Screen1)

onPress={()=> this.props.navigation.navigate('DaretDetail',{
                                                           Name:this.state.nom , 
                                                           Amount: this.state.montant,

屏幕2

 render () {

        const name = this.props.navigation.state.params('Name');
        const amount = this.props.navigation.state.params('Amount');

        console.log(navigation);
    return ( 

    <View>
        <View>
        {JSON.stringify(name)}
        </View>

        <View>
        {JSON.stringify(amount)}
        </View>
    </View>

0 个答案:

没有答案