mirror of
https://github.com/status-im/react-navigation.git
synced 2025-02-23 16:48:22 +00:00
Export getNavigationActionCreators (#4258)
* Export getNavigationActionCreators `react-navigation-redux-helpers` generally needs to duplicate whatever `createNavigationCreator` does. As of `react-navigation@2.0`, that includes using `getNavigationActionCreators` to construct the top-level `NavigationScreenProp`. This PR isn't strictly needed, as it's possible to import from the file directly. But that's a brittle approach, and not particularly discoverable for anybody attempting to use a "non-stateful" navigator with their state management library of choice. * Further refinements after writing the new helper * Final refinement of NavigationScreenProp's relationship with _DefaultActionCreators * Resolve merge conflicts
This commit is contained in:
parent
1d2ce862c2
commit
1e7d8d55c3
39
flow/react-navigation.js
vendored
39
flow/react-navigation.js
vendored
@ -487,6 +487,10 @@ declare module 'react-navigation' {
|
|||||||
};
|
};
|
||||||
|
|
||||||
declare export type NavigationScreenProp<+S> = {
|
declare export type NavigationScreenProp<+S> = {
|
||||||
|
...$ObjMap<
|
||||||
|
_DefaultActionCreators,
|
||||||
|
<Args>((...args: Args) => *) => (...args: Args) => boolean
|
||||||
|
>,
|
||||||
+state: S,
|
+state: S,
|
||||||
dispatch: NavigationDispatch,
|
dispatch: NavigationDispatch,
|
||||||
addListener: (
|
addListener: (
|
||||||
@ -495,21 +499,6 @@ declare module 'react-navigation' {
|
|||||||
) => NavigationEventSubscription,
|
) => NavigationEventSubscription,
|
||||||
getParam: (paramName: string, fallback?: any) => any,
|
getParam: (paramName: string, fallback?: any) => any,
|
||||||
isFocused: () => boolean,
|
isFocused: () => boolean,
|
||||||
// Shared action creators that exist for all routers
|
|
||||||
goBack: (routeKey?: ?string) => boolean,
|
|
||||||
navigate: (
|
|
||||||
routeName:
|
|
||||||
| string
|
|
||||||
| {
|
|
||||||
routeName: string,
|
|
||||||
params?: NavigationParams,
|
|
||||||
action?: NavigationNavigateAction,
|
|
||||||
key?: string,
|
|
||||||
},
|
|
||||||
params?: NavigationParams,
|
|
||||||
action?: NavigationNavigateAction
|
|
||||||
) => boolean,
|
|
||||||
setParams: (newParams: NavigationParams) => boolean,
|
|
||||||
// StackRouter action creators
|
// StackRouter action creators
|
||||||
pop?: (n?: number, params?: { immediate?: boolean }) => boolean,
|
pop?: (n?: number, params?: { immediate?: boolean }) => boolean,
|
||||||
popToTop?: (params?: { immediate?: boolean }) => boolean,
|
popToTop?: (params?: { immediate?: boolean }) => boolean,
|
||||||
@ -760,6 +749,26 @@ declare module 'react-navigation' {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
declare type _DefaultActionCreators = {|
|
||||||
|
goBack: (routeKey?: ?string) => NavigationBackAction,
|
||||||
|
navigate: (
|
||||||
|
routeName:
|
||||||
|
| string
|
||||||
|
| {
|
||||||
|
routeName: string,
|
||||||
|
params?: NavigationParams,
|
||||||
|
action?: NavigationNavigateAction,
|
||||||
|
key?: string,
|
||||||
|
},
|
||||||
|
params?: NavigationParams,
|
||||||
|
action?: NavigationNavigateAction
|
||||||
|
) => NavigationNavigateAction,
|
||||||
|
setParams: (newParams: NavigationParams) => NavigationSetParamsAction,
|
||||||
|
|};
|
||||||
|
declare export function getNavigationActionCreators(
|
||||||
|
route: NavigationRoute | NavigationState
|
||||||
|
): _DefaultActionCreators;
|
||||||
|
|
||||||
declare type _RouterProp<S: NavigationState, O: {}> = {
|
declare type _RouterProp<S: NavigationState, O: {}> = {
|
||||||
router: NavigationRouter<S, O>,
|
router: NavigationRouter<S, O>,
|
||||||
};
|
};
|
||||||
|
3
src/react-navigation.js
vendored
3
src/react-navigation.js
vendored
@ -71,6 +71,9 @@ module.exports = {
|
|||||||
get DrawerActions() {
|
get DrawerActions() {
|
||||||
return require('./routers/DrawerActions').default;
|
return require('./routers/DrawerActions').default;
|
||||||
},
|
},
|
||||||
|
get getNavigationActionCreators() {
|
||||||
|
return require('./routers/getNavigationActionCreators').default;
|
||||||
|
},
|
||||||
|
|
||||||
// Routers
|
// Routers
|
||||||
get StackRouter() {
|
get StackRouter() {
|
||||||
|
@ -24,6 +24,9 @@ module.exports = {
|
|||||||
get DrawerActions() {
|
get DrawerActions() {
|
||||||
return require('./routers/DrawerActions').default;
|
return require('./routers/DrawerActions').default;
|
||||||
},
|
},
|
||||||
|
get getNavigationActionCreators() {
|
||||||
|
return require('./routers/getNavigationActionCreators').default;
|
||||||
|
},
|
||||||
|
|
||||||
// Routers
|
// Routers
|
||||||
get StackRouter() {
|
get StackRouter() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user