mirror of
https://github.com/status-im/react-navigation.git
synced 2025-02-25 01:28:16 +00:00
Hoist navigation action creators for router above those for child router
This commit is contained in:
parent
5598c3e28f
commit
665736d754
@ -1,5 +1,6 @@
|
|||||||
import getChildEventSubscriber from './getChildEventSubscriber';
|
import getChildEventSubscriber from './getChildEventSubscriber';
|
||||||
import getChildRouter from './getChildRouter';
|
import getChildRouter from './getChildRouter';
|
||||||
|
import getNavigationActionCreators from './routers/getNavigationActionCreators';
|
||||||
import invariant from './utils/invariant';
|
import invariant from './utils/invariant';
|
||||||
|
|
||||||
const createParamGetter = route => (paramName, defaultValue) => {
|
const createParamGetter = route => (paramName, defaultValue) => {
|
||||||
@ -40,7 +41,9 @@ function getChildNavigation(navigation, childKey, getCurrentParentNavigation) {
|
|||||||
...(childRouter
|
...(childRouter
|
||||||
? childRouter.getActionCreators(focusedGrandChildRoute, childRoute.key)
|
? childRouter.getActionCreators(focusedGrandChildRoute, childRoute.key)
|
||||||
: {}),
|
: {}),
|
||||||
|
...getNavigationActionCreators(childRoute),
|
||||||
};
|
};
|
||||||
|
|
||||||
const actionHelpers = {};
|
const actionHelpers = {};
|
||||||
Object.keys(actionCreators).forEach(actionName => {
|
Object.keys(actionCreators).forEach(actionName => {
|
||||||
actionHelpers[actionName] = (...args) => {
|
actionHelpers[actionName] = (...args) => {
|
||||||
|
@ -8,7 +8,6 @@ import StateUtils from '../StateUtils';
|
|||||||
import validateRouteConfigMap from './validateRouteConfigMap';
|
import validateRouteConfigMap from './validateRouteConfigMap';
|
||||||
import invariant from '../utils/invariant';
|
import invariant from '../utils/invariant';
|
||||||
import { generateKey } from './KeyGenerator';
|
import { generateKey } from './KeyGenerator';
|
||||||
import getNavigationActionCreators from './getNavigationActionCreators';
|
|
||||||
|
|
||||||
function isEmpty(obj) {
|
function isEmpty(obj) {
|
||||||
if (!obj) return true;
|
if (!obj) return true;
|
||||||
@ -166,7 +165,6 @@ export default (routeConfigs, stackConfig = {}) => {
|
|||||||
|
|
||||||
getActionCreators(route, navStateKey) {
|
getActionCreators(route, navStateKey) {
|
||||||
return {
|
return {
|
||||||
...getNavigationActionCreators(route),
|
|
||||||
...getCustomActionCreators(route, navStateKey),
|
...getCustomActionCreators(route, navStateKey),
|
||||||
pop: (n, params) =>
|
pop: (n, params) =>
|
||||||
StackActions.pop({
|
StackActions.pop({
|
||||||
|
@ -5,7 +5,6 @@ import createConfigGetter from './createConfigGetter';
|
|||||||
import NavigationActions from '../NavigationActions';
|
import NavigationActions from '../NavigationActions';
|
||||||
import StackActions from './StackActions';
|
import StackActions from './StackActions';
|
||||||
import validateRouteConfigMap from './validateRouteConfigMap';
|
import validateRouteConfigMap from './validateRouteConfigMap';
|
||||||
import getNavigationActionCreators from './getNavigationActionCreators';
|
|
||||||
|
|
||||||
const defaultActionCreators = (route, navStateKey) => ({});
|
const defaultActionCreators = (route, navStateKey) => ({});
|
||||||
|
|
||||||
@ -109,10 +108,7 @@ export default (routeConfigs, config = {}) => {
|
|||||||
childRouters,
|
childRouters,
|
||||||
|
|
||||||
getActionCreators(route, stateKey) {
|
getActionCreators(route, stateKey) {
|
||||||
return {
|
return getCustomActionCreators(route, stateKey);
|
||||||
...getNavigationActionCreators(route),
|
|
||||||
...getCustomActionCreators(route, stateKey),
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getStateForAction(action, inputState) {
|
getStateForAction(action, inputState) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user