mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-29 09:18:02 +08:00
609 B
609 B
withNavigation
withNavigation is a Higher Order Component which passes the navigation prop into wrapped Component. It's useful when you cannnot pass the navigation prop into into the component directly, or don't want to pass it in case of a deeply nested child.
Example
import { Button } 'react-native';
import { withNavigation } from 'react-navigation';
const MyComponent = ({ to, navigation }) => (
<Button title={`navigate to ${to}`} onPress={() => navigation.navigate(to)} />
);
const MyComponentWithNavigation = withNavigation(MyComponent);