Navigation Action Helpers at root (#4151)

This commit is contained in:
Eric Vicenti 2018-05-07 12:56:35 -07:00 committed by Brent Vatne
parent 2fd7284fe2
commit 364144d639
3 changed files with 8 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import { polyfill } from 'react-lifecycles-compat';
import { BackHandler } from './PlatformHelpers'; import { BackHandler } from './PlatformHelpers';
import NavigationActions from './NavigationActions'; import NavigationActions from './NavigationActions';
import invariant from './utils/invariant'; import invariant from './utils/invariant';
import getNavigationActionCreators from './routers/getNavigationActionCreators';
import docsUrl from './utils/docsUrl'; import docsUrl from './utils/docsUrl';
function isStateful(props) { function isStateful(props) {
@ -359,6 +360,11 @@ export default function createNavigationContainer(Component) {
}; };
}, },
}; };
const actionCreators = getNavigationActionCreators(nav);
Object.keys(actionCreators).forEach(actionName => {
this._navigation[actionName] = (...args) =>
this.dispatch(actionCreators[actionName](...args));
});
} }
navigation = this._navigation; navigation = this._navigation;
} }

View File

@ -164,7 +164,7 @@ export default (routeConfigs, stackConfig = {}) => {
getActionCreators(route, navStateKey) { getActionCreators(route, navStateKey) {
return { return {
...getNavigationActionCreators(route, navStateKey), ...getNavigationActionCreators(route),
...getCustomActionCreators(route, navStateKey), ...getCustomActionCreators(route, navStateKey),
pop: (n, params) => pop: (n, params) =>
StackActions.pop({ StackActions.pop({

View File

@ -108,7 +108,7 @@ export default (routeConfigs, config = {}) => {
getActionCreators(route, stateKey) { getActionCreators(route, stateKey) {
return { return {
...getNavigationActionCreators(route, stateKey), ...getNavigationActionCreators(route),
...getCustomActionCreators(route, stateKey), ...getCustomActionCreators(route, stateKey),
}; };
}, },