Remove flow (#3350)

* Remove flow types from src

* Finish removing Flow

* Clear out flow-typed, some flow mentions in docs, website flow usage, and some other config
This commit is contained in:
Brent Vatne
2018-01-24 17:52:09 -08:00
committed by Eric Vicenti
parent 276249c4c7
commit ecfa38bfd2
119 changed files with 1967 additions and 15861 deletions

View File

@@ -1,48 +1,23 @@
/* @flow */
import React from 'react';
import { BackHandler, Linking } from './PlatformHelpers';
import NavigationActions from './NavigationActions';
import addNavigationHelpers from './addNavigationHelpers';
import invariant from './utils/invariant';
import type {
NavigationAction,
NavigationState,
NavigationScreenProp,
NavigationNavigator,
PossiblyDeprecatedNavigationAction,
NavigationInitAction,
NavigationContainerProps,
NavigationContainer,
} from './TypeDefinition';
type State<NavState> = {
nav: ?NavState,
};
/**
* Create an HOC that injects the navigation and manages the navigation state
* in case it's not passed from above.
* This allows to use e.g. the StackNavigator and TabNavigator as root-level
* components.
*/
export default function createNavigationContainer<S: NavigationState, O: {}>(
// Let the NavigationNavigator props flowwwww
Component: NavigationNavigator<S, O, *>
): NavigationContainer<S, O, *> {
class NavigationContainer extends React.Component<
NavigationContainerProps<S, O>,
State<S>
> {
subs: ?{
remove: () => void,
} = null;
export default function createNavigationContainer(Component) {
class NavigationContainer extends React.Component {
subs = null;
static router = Component.router;
static navigationOptions = null;
constructor(props: NavigationContainerProps<S, O>) {
constructor(props) {
super(props);
this._validateProps(props);
@@ -54,11 +29,11 @@ export default function createNavigationContainer<S: NavigationState, O: {}>(
};
}
_isStateful(): boolean {
_isStateful() {
return !this.props.navigation;
}
_validateProps(props: NavigationContainerProps<S, O>) {
_validateProps(props) {
if (this._isStateful()) {
return;
}
@@ -79,7 +54,7 @@ export default function createNavigationContainer<S: NavigationState, O: {}>(
}
}
_urlToPathAndParams(url: string) {
_urlToPathAndParams(url) {
const params = {};
const delimiter = this.props.uriPrefix || '://';
let path = url.split(delimiter)[1];
@@ -94,7 +69,7 @@ export default function createNavigationContainer<S: NavigationState, O: {}>(
};
}
_handleOpenURL = ({ url }: { url: string }) => {
_handleOpenURL = ({ url }) => {
const parsedUrl = this._urlToPathAndParams(url);
if (parsedUrl) {
const { path, params } = parsedUrl;
@@ -105,11 +80,7 @@ export default function createNavigationContainer<S: NavigationState, O: {}>(
}
};
_onNavigationStateChange(
prevNav: NavigationState,
nav: NavigationState,
action: NavigationAction
) {
_onNavigationStateChange(prevNav, nav, action) {
if (
typeof this.props.onNavigationStateChange === 'undefined' &&
this._isStateful() &&
@@ -138,7 +109,7 @@ export default function createNavigationContainer<S: NavigationState, O: {}>(
}
}
componentWillReceiveProps(nextProps: NavigationContainerProps<S, O>) {
componentWillReceiveProps(nextProps) {
this._validateProps(nextProps);
}
@@ -160,9 +131,7 @@ export default function createNavigationContainer<S: NavigationState, O: {}>(
Linking.addEventListener('url', this._handleOpenURL);
Linking.getInitialURL().then(
(url: ?string) => url && this._handleOpenURL({ url })
);
Linking.getInitialURL().then(url => url && this._handleOpenURL({ url }));
}
componentWillUnmount() {
@@ -171,9 +140,8 @@ export default function createNavigationContainer<S: NavigationState, O: {}>(
}
// Per-tick temporary storage for state.nav
_nav: ?S;
dispatch = (inputAction: PossiblyDeprecatedNavigationAction) => {
dispatch = inputAction => {
const action = NavigationActions.mapDeprecatedActionAndWarn(inputAction);
if (!this._isStateful()) {
return false;
@@ -193,8 +161,6 @@ export default function createNavigationContainer<S: NavigationState, O: {}>(
return false;
};
_navigation: ?NavigationScreenProp<NavigationState>;
render() {
let navigation = this.props.navigation;
if (this._isStateful()) {