0
我正在使用我的React Native应用程序的“react-native-router-flux”,我似乎无法弄清楚我的自定义导航栏应该如何与我的组件进行通信?NavBar应该如何与React Native中的组件进行通信?
我有以下代码。
NavigationRouter.js:
<Scene key='addDrillScreen' component={AddDrillScreen} navBar={AddDrillNavBar} />
AddDrillScreen.js:
class AddDrillScreen extends React.Component {
performSave() {
// Want to call performSave() when NavBar is clicked
}
}
AddDrillNavBar.js:
class AddDrillNavBar extends React.Component {
render() {
return (
<View style={styles.saveButton}>
<TouchableOpacity onPress={() => {
// ??? How do I trigger the performSave() on my AddDrillScreen?
}}>
<Text style={styles.saveButtonText}>Save</Text>
</TouchableOpacity>
</View>
)
}
我不明白这两个怎么沟通
这是一个类似的问题。希望这可以解决您的问题。 http://stackoverflow.com/questions/32846655/how-do-i-call-execute-a-function-from-another-component-in-react-native –