Files
react-navigation/src/views/withNavigation.js
Mike Grabowski bbe9caff06 Fix eslint issues and turn on prettier by default (#1195)
* Automatically generate prop-types from Flow

* Remove propTypes usage

* Fix flow

* Modify some eslint settings

* Fix flowtype

* Lint tweaks

* use prop-types pkg

* Run prettier

* Fix flow

* Fix few lint issues

* Make eslint pass

* Run lint on tests

* Fix flow

* Fixes

* Alphabetical

* Trailing comma: ES5 for website compat, also fix config/paths

* Apply eslint --fix only to src now

* Fix missing transitionconfig

* Update TypeDefinition.js

* New stuff

* Unstage website and examples

* reformat code

* Update circle.yml
2017-04-24 17:31:22 +05:30

32 lines
868 B
JavaScript

/* @flow */
import React from 'react';
import propTypes from 'prop-types';
import hoistStatics from 'hoist-non-react-statics';
import type { NavigationState, NavigationAction } from '../TypeDefinition';
type Context = {
navigation: InjectedProps<NavigationState, NavigationAction>,
};
type InjectedProps = {
navigation: InjectedProps<NavigationState, NavigationAction>,
};
export default function withNavigation<T: *>(
Component: ReactClass<T & InjectedProps>,
) {
const componentWithNavigation = (props: T, { navigation }: Context) => (
<Component {...props} navigation={navigation} />
);
componentWithNavigation.displayName = `withNavigation(${Component.displayName || Component.name})`;
componentWithNavigation.contextTypes = {
navigation: propTypes.object.isRequired,
};
return hoistStatics(componentWithNavigation, Component);
}