我有两个组件我想将页面上的某些属性数据传递给其他页面/组件。但无法用道具做到这一点。组件之间的数据传输反应原生
<TouchableOpacity onPress={() => {this.navigateTo('component2'); setState(url: 'www.xyz.com', data: 'abc' }>
<View style={{ flexDirection: 'row', height: 60, justifyContent: 'center', alignItems: 'center', paddingLeft: 10 }}>
<Image source={deals} />
<View style={{ flex: 1 }}>
<Text style={{ color: '#000' }}> Deal Center </Text>
</View>
</View>
</TouchableOpacity>
并希望从component2中读取状态。任何人都可以请帮助
调用你的方法上点击
在第二组件,您可以访问数据是否使用助焊剂/终极版/ RxJS? –
http://stackoverflow.com/questions/38203791/communicate-between-components-in-react-native-child-parent –
小姑娘特卖延伸元器件{ 静态propTypes = { popRoute:React.PropTypes.func, 导航:React.PropTypes.shape({ 键:React.PropTypes.string, }), } 构造(道具){ 超级(道具); this.state = { name:'Deals', }; } navigateTo(route){ this.props.navigateTo(route,'home'); } –