mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-24 04:25:34 +08:00
Fix NavigationEvent types (#3384)
* Fix SimpleTabs types
dca37627a2 broke the types, but it wasn't noticed because Flow wasn't in the CI. This fixes the types; separate PR coming to add Flow to the CI.
* Refine type of NavigationEventListener callback
Instead of typing the callback as `Function`, we're now using the precise type provided by @ericvicenti
* NavigationEventListener -> NavigationEventSubscription
This commit is contained in:
committed by
Eric Vicenti
parent
d1d81d7033
commit
0d3d83bd90
@@ -2,7 +2,10 @@
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import type { NavigationScreenProp, EventListener } from 'react-navigation';
|
||||
import type {
|
||||
NavigationScreenProp,
|
||||
NavigationEventSubscription,
|
||||
} from 'react-navigation';
|
||||
|
||||
import * as React from 'react';
|
||||
import { Button, ScrollView, StatusBar } from 'react-native';
|
||||
@@ -52,10 +55,10 @@ class MyHomeScreen extends React.Component<MyHomeScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Welcome',
|
||||
};
|
||||
_s0: EventListener;
|
||||
_s1: EventListener;
|
||||
_s2: EventListener;
|
||||
_s3: EventListener;
|
||||
_s0: NavigationEventSubscription;
|
||||
_s1: NavigationEventSubscription;
|
||||
_s2: NavigationEventSubscription;
|
||||
_s3: NavigationEventSubscription;
|
||||
|
||||
componentDidMount() {
|
||||
this._s0 = this.props.navigation.addListener('willFocus', this._onWF);
|
||||
@@ -95,10 +98,10 @@ class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Photos',
|
||||
};
|
||||
_s0: EventListener;
|
||||
_s1: EventListener;
|
||||
_s2: EventListener;
|
||||
_s3: EventListener;
|
||||
_s0: NavigationEventSubscription;
|
||||
_s1: NavigationEventSubscription;
|
||||
_s2: NavigationEventSubscription;
|
||||
_s3: NavigationEventSubscription;
|
||||
|
||||
componentDidMount() {
|
||||
this._s0 = this.props.navigation.addListener('willFocus', this._onWF);
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import type { NavigationScreenProp, EventListener } from 'react-navigation';
|
||||
import type {
|
||||
NavigationScreenProp,
|
||||
NavigationEventSubscription,
|
||||
} from 'react-navigation';
|
||||
|
||||
import React from 'react';
|
||||
import { Button, Platform, ScrollView, StatusBar, View } from 'react-native';
|
||||
@@ -45,7 +48,15 @@ MyHomeScreen.navigationOptions = {
|
||||
),
|
||||
};
|
||||
|
||||
class MyPeopleScreen extends React.Component {
|
||||
type MyPeopleScreenProps = {
|
||||
navigation: NavigationScreenProp<*>,
|
||||
};
|
||||
class MyPeopleScreen extends React.Component<MyPeopleScreenProps> {
|
||||
_s0: NavigationEventSubscription;
|
||||
_s1: NavigationEventSubscription;
|
||||
_s2: NavigationEventSubscription;
|
||||
_s3: NavigationEventSubscription;
|
||||
|
||||
static navigationOptions = {
|
||||
tabBarLabel: 'People',
|
||||
tabBarIcon: ({ tintColor, focused }) => (
|
||||
@@ -77,7 +88,15 @@ class MyPeopleScreen extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
class MyChatScreen extends React.Component {
|
||||
type MyChatScreenProps = {
|
||||
navigation: NavigationScreenProp<*>,
|
||||
};
|
||||
class MyChatScreen extends React.Component<MyChatScreenProps> {
|
||||
_s0: NavigationEventSubscription;
|
||||
_s1: NavigationEventSubscription;
|
||||
_s2: NavigationEventSubscription;
|
||||
_s3: NavigationEventSubscription;
|
||||
|
||||
static navigationOptions = {
|
||||
tabBarLabel: 'Chat',
|
||||
tabBarIcon: ({ tintColor, focused }) => (
|
||||
@@ -156,10 +175,10 @@ type SimpleTabsContainerProps = {
|
||||
|
||||
class SimpleTabsContainer extends React.Component<SimpleTabsContainerProps> {
|
||||
static router = SimpleTabs.router;
|
||||
_s0: EventListener;
|
||||
_s1: EventListener;
|
||||
_s2: EventListener;
|
||||
_s3: EventListener;
|
||||
_s0: NavigationEventSubscription;
|
||||
_s1: NavigationEventSubscription;
|
||||
_s2: NavigationEventSubscription;
|
||||
_s3: NavigationEventSubscription;
|
||||
|
||||
componentDidMount() {
|
||||
this._s0 = this.props.navigation.addListener('willFocus', this._onAction);
|
||||
|
||||
Reference in New Issue
Block a user