diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 75bc217615..b58f3778ae 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -18,6 +18,7 @@ // Edward Sammut Alessi // Jérémy Magrin // Luca Campana +// Ullrich Schaefer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -1165,9 +1166,12 @@ export function withNavigation( Component: React.ComponentType ): React.ComponentType }>; +export interface NavigationFocusInjectedProps extends NavigationInjectedProps { + isFocused: boolean; +} export function withNavigationFocus( - Component: React.ComponentType -): React.ComponentType; + Component: React.ComponentType +): React.ComponentType }>; /** * SafeAreaView Component diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index 38aa495240..40aa75cbc3 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -42,6 +42,8 @@ import { NavigationContainerComponent, withNavigation, NavigationInjectedProps, + withNavigationFocus, + NavigationFocusInjectedProps } from 'react-navigation'; // Constants @@ -532,3 +534,19 @@ const BackButtonWithNavigation = withNavigation(MyBackButton); const BackButtonInstance = { const backButtonRef = ref; }} />; + +// Test withNavigationFocus + +interface MyFocusedComponentProps { expectsFocus: boolean; } +class MyFocusedComponent extends React.Component { + render() { + return