我有Component App返回(ComponentMain,ComponentA),其中ComponentMain是createAppContainer。因此,在组件A内部,我想浏览ComponentMain。有可能吗?
答案 0 :(得分:0)
您可以将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);