2017-08-11 54 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? –

相關問題