react-navigation/docs/api/withNavigation.md
Jan Peer Stöcklmair 661d01dc54 Docs: typo (#1783)
* Docs: typo
2017-06-27 17:27:54 -05:00

605 B

withNavigation

withNavigation is a Higher Order Component which passes the navigation prop into a wrapped Component. It's useful when you cannot pass the navigation prop 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);