2017-08-11 55 views
0

你好我试图将数据传递到另一个画面,我这样做:如何使用反应原生路由器通量将数据传递到另一个屏幕?

constructor(props) { 
    super(props); 
    this.state { 
     qty: '', 
    } 
} 

的TextInput:

<TextInput 
    placeholder="Quantity" 
    underlineColorAndroid={'rgba(0,0,0,0)'} 
    onChangeText={(text) => this.setState({qty: text})} 
    numberOfLines={4} 
    style={styles.textstyleinputed1} 
/> 

按钮:

<TouchableHighlight style = {styles.button} onPress={()=>Actions.gotoMap(this.state.qty)} underlayColor="transparent"> 
    <Text style={styles.buttonText}>NEXT</Text> 
</TouchableHighlight> 

这是我在如何调用其他屏幕

<Text>{this.props.qty}</Text> 

并没有显示。我不知道缺少什么。

回答

2

当您通过使用动作从路由器的流量数据,你必须定义你想传递给其他组件这样的道具名称:

Actions.gotoMap({ QTY : this.state.qty });

然后你就可以在gotoMap成分得到像这样:

<Text>{this.props.QTY}</Text>

我希望这个答案可以帮助你:)

+0

是它瓦特orking @ggnades? –

相关问题