Вы можете использовать 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);