mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-28 12:25:21 +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
@@ -414,7 +414,23 @@ export type NavigationProp<S> = {
|
||||
dispatch: NavigationDispatch,
|
||||
};
|
||||
|
||||
export type EventListener = {
|
||||
export type EventType =
|
||||
| 'willFocus'
|
||||
| 'didFocus'
|
||||
| 'willBlur'
|
||||
| 'didBlur'
|
||||
| 'action';
|
||||
|
||||
export type NavigationEventPayload = {
|
||||
type: EventType,
|
||||
action: NavigationAction,
|
||||
state: NavigationState,
|
||||
lastState: NavigationState,
|
||||
};
|
||||
|
||||
export type NavigationEventCallback = (payload: NavigationEventPayload) => void;
|
||||
|
||||
export type NavigationEventSubscription = {
|
||||
remove: () => void,
|
||||
};
|
||||
|
||||
@@ -428,7 +444,10 @@ export type NavigationScreenProp<+S> = {
|
||||
action?: NavigationNavigateAction
|
||||
) => boolean,
|
||||
setParams: (newParams: NavigationParams) => boolean,
|
||||
addListener: (eventName: string, callback: Function) => EventListener,
|
||||
addListener: (
|
||||
eventName: string,
|
||||
callback: NavigationEventCallback
|
||||
) => NavigationEventSubscription,
|
||||
};
|
||||
|
||||
export type NavigationNavigatorProps<O: {}, S: {}> = {
|
||||
|
||||
Reference in New Issue
Block a user