我有Component App返回(ComponentMain,ComponentA),ComponentMain是一个createAppContainer。因此,在组件A中我想要导航ComponentMain。这是可能的?
您可以将withNavigation
用于外部stackNavigator组件,以使用navigation
作为道具。
以下是如何使用withNavigation
的示例:
import React from 'react';
import { Button } from 'react-native';
import { withNavigation } from 'react-navigation';
class ComponentA extends React.Component {
render() {
return <Button title="Back" onPress={() => { this.props.navigation.goBack() }} />;
}
}
// withNavigation returns a component that wraps MyBackButton and passes in the
// navigation prop
export default withNavigation(ComponentA);