How to pass values to other component in React-Native-Router-Flux?

后端 未结 5 1599
误落风尘
误落风尘 2020-12-08 06:44

My code is:

...

 


...
com1.js         


        
5条回答
  •  没有蜡笔的小新
    2020-12-08 07:19

    Pass data through an Input,

       import React, { Component } from 'react';
       import { Text, View, TextInput, TouchableOpacity } from 'react-native';
       import { Actions } from 'react-native-router-flux';
    
       export default class Com1 extends Component {
       state = { text: '' };
          render() {
           return (
              
                  this.setState({ text })}
                />
        
       Get Data
        
        
        );
    }
    
    onPressNext() {
        Actions.Com2({text: this.state.text });
    }
    }
    

    To get value in the second Page

       export default class Com2 extends Component {
    
          render() {
             return (
            
             
              {this.props.text}
             
           
        );
      }
     }
    

    You can refer to this link: https://react-native-solutions.blogspot.com/2018/07/passing-data-between-screens-in-react.html

提交回复
热议问题