Adding a test that fails

This commit is contained in:
Ullrich Schäfer
2018-06-28 14:29:38 +02:00
parent 80d50f06cf
commit 455ab41dbb
@@ -41,6 +41,7 @@ import {
NavigationScreenComponent,
NavigationContainerComponent,
withNavigation,
withNavigationFocus,
NavigationInjectedProps,
} from 'react-navigation';
@@ -532,3 +533,19 @@ const BackButtonWithNavigation = withNavigation<BackButtonProps>(MyBackButton);
const BackButtonInstance = <BackButtonWithNavigation
title="Back" onRef={ref => { const backButtonRef = ref; }}
/>;
// Test withNavigationFocus
interface MyFocusedComponentProps { expectsFocus: boolean; }
class MyFocusedComponent extends React.Component<MyFocusedComponentProps & NavigationInjectedProps> {
render() {
return <button title={`${this.props.expectsFocus} vs ${this.props.isFocused}`} onClick={() => { this.props.navigation.goBack(); }} />;
}
}
// withNavigationFocus returns a component that wraps MyFocusedComponent and passes in the
// navigation and isFocused prop
const MyFocusedComponentWithNavigationFocus = withNavigationFocus<MyFocusedComponentProps>(MyFocusedComponent);
const MyFocusedComponentInstance = <MyFocusedComponentWithNavigationFocus
expectsFocus={true} onRef={ref => { const backButtonRef = ref; }}
/>;