i具有componentMain的组件应用返回(componentMain,componenta)是一个创建者。因此,在组件A内部我想导航componentmain。可能?
您可以将withNavigation
用于外部stacknavigator组件将navigation
用作Prop。
这是如何使用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);