From b41d268572332c4ec89dbb0a923ec2fa8a78cbea Mon Sep 17 00:00:00 2001 From: Eric Vicenti Date: Sun, 25 Mar 2018 13:49:09 -0400 Subject: [PATCH] withNavigation improvement (#3834) The navigation prop should also pass through, and be prioritized over context because it is more explicit This also fixes an incorrect warning/invariant --- packages/react-navigation/src/views/withNavigation.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/react-navigation/src/views/withNavigation.js b/packages/react-navigation/src/views/withNavigation.js index c2fe0085..318ff478 100644 --- a/packages/react-navigation/src/views/withNavigation.js +++ b/packages/react-navigation/src/views/withNavigation.js @@ -10,12 +10,14 @@ export default function withNavigation(Component) { Component.name})`; render() { + const navigationProp = this.props.navigation; return ( - {navigation => { + {navigationContext => { + const navigation = navigationProp || navigationContext; invariant( !!navigation, - 'withNavigationFocus can only be used on a view hierarchy of a navigator. The wrapped component is unable to get access to navigation from props or context.' + 'withNavigation can only be used on a view hierarchy of a navigator. The wrapped component is unable to get access to navigation from props or context.' ); return (