mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-26 23:06:03 +08:00
Update/Fix Prettier + Eslint config for codebase
Run Prettier/Eslint on entire codebase, fix issues
This commit is contained in:
committed by
Adam Miskiewicz
parent
a301b41479
commit
f3a958dca1
@@ -30,7 +30,7 @@ function _getUuid() {
|
||||
|
||||
export default (
|
||||
routeConfigs: NavigationRouteConfigMap,
|
||||
stackConfig: NavigationStackRouterConfig = {},
|
||||
stackConfig: NavigationStackRouterConfig = {}
|
||||
): NavigationRouter<*, *, *> => {
|
||||
// Fail fast on invalid route definitions
|
||||
validateRouteConfigMap(routeConfigs);
|
||||
@@ -49,9 +49,7 @@ export default (
|
||||
}
|
||||
});
|
||||
|
||||
const {
|
||||
initialRouteParams,
|
||||
} = stackConfig;
|
||||
const { initialRouteParams } = stackConfig;
|
||||
|
||||
const initialRouteName = stackConfig.initialRouteName || routeNames[0];
|
||||
|
||||
@@ -90,7 +88,7 @@ export default (
|
||||
|
||||
getStateForAction(
|
||||
passedAction: NavigationStackAction,
|
||||
state: ?NavigationState,
|
||||
state: ?NavigationState
|
||||
) {
|
||||
const action = NavigationActions.mapDeprecatedActionAndWarn(passedAction);
|
||||
|
||||
@@ -117,7 +115,7 @@ export default (
|
||||
NavigationActions.navigate({
|
||||
routeName: initialRouteName,
|
||||
params: initialRouteParams,
|
||||
}),
|
||||
})
|
||||
);
|
||||
}
|
||||
const params = (route.params ||
|
||||
@@ -167,8 +165,8 @@ export default (
|
||||
const childRouter = childRouters[action.routeName];
|
||||
let route;
|
||||
if (childRouter) {
|
||||
const childAction = action.action ||
|
||||
NavigationActions.init({ params: action.params });
|
||||
const childAction =
|
||||
action.action || NavigationActions.init({ params: action.params });
|
||||
route = {
|
||||
params: action.params,
|
||||
...childRouter.getStateForAction(childAction),
|
||||
@@ -194,12 +192,12 @@ export default (
|
||||
if (childRouter) {
|
||||
// For each child router, start with a blank state
|
||||
const initChildRoute = childRouter.getStateForAction(
|
||||
NavigationActions.init(),
|
||||
NavigationActions.init()
|
||||
);
|
||||
// Then check to see if the router handles our navigate action
|
||||
const navigatedChildRoute = childRouter.getStateForAction(
|
||||
action,
|
||||
initChildRoute,
|
||||
initChildRoute
|
||||
);
|
||||
let routeToPush = null;
|
||||
if (navigatedChildRoute === null) {
|
||||
@@ -223,7 +221,7 @@ export default (
|
||||
if (action.type === NavigationActions.SET_PARAMS) {
|
||||
const lastRoute = state.routes.find(
|
||||
/* $FlowFixMe */
|
||||
(route: *) => route.key === action.key,
|
||||
(route: *) => route.key === action.key
|
||||
);
|
||||
if (lastRoute) {
|
||||
const params = {
|
||||
@@ -264,7 +262,7 @@ export default (
|
||||
};
|
||||
delete route.type;
|
||||
return route;
|
||||
},
|
||||
}
|
||||
),
|
||||
index: action.index,
|
||||
};
|
||||
@@ -275,7 +273,7 @@ export default (
|
||||
if (action.key) {
|
||||
const backRoute = state.routes.find(
|
||||
/* $FlowFixMe */
|
||||
(route: *) => route.key === action.key,
|
||||
(route: *) => route.key === action.key
|
||||
);
|
||||
/* $FlowFixMe */
|
||||
backRouteIndex = state.routes.indexOf(backRoute);
|
||||
@@ -295,7 +293,7 @@ export default (
|
||||
},
|
||||
|
||||
getPathAndParamsForState(
|
||||
state: NavigationState,
|
||||
state: NavigationState
|
||||
): { path: string, params?: NavigationParams } {
|
||||
const route = state.routes[state.index];
|
||||
const routeName = route.routeName;
|
||||
@@ -359,14 +357,15 @@ export default (
|
||||
if (childRouters[matchedRouteName]) {
|
||||
nestedAction = childRouters[matchedRouteName].getActionForPathAndParams(
|
||||
/* $FlowFixMe */
|
||||
pathMatch.slice(pathMatchKeys.length).join('/'),
|
||||
pathMatch.slice(pathMatchKeys.length).join('/')
|
||||
);
|
||||
}
|
||||
|
||||
// reduce the items of the query string. any query params may
|
||||
// be overridden by path params
|
||||
const queryParams = (queryString || '').split('&').reduce(
|
||||
(result: *, item: string) => {
|
||||
const queryParams = (queryString || '')
|
||||
.split('&')
|
||||
.reduce((result: *, item: string) => {
|
||||
if (item !== '') {
|
||||
const nextResult = result || {};
|
||||
const [key, value] = item.split('=');
|
||||
@@ -374,15 +373,14 @@ export default (
|
||||
return nextResult;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
null,
|
||||
);
|
||||
}, null);
|
||||
|
||||
// reduce the matched pieces of the path into the params
|
||||
// of the route. `params` is null if there are no params.
|
||||
/* $FlowFixMe */
|
||||
const params = pathMatch.slice(1).reduce(
|
||||
(result: *, matchResult: *, i: number) => {
|
||||
const params = pathMatch
|
||||
.slice(1)
|
||||
.reduce((result: *, matchResult: *, i: number) => {
|
||||
const key = pathMatchKeys[i];
|
||||
if (key.asterisk || !key) {
|
||||
return result;
|
||||
@@ -391,9 +389,7 @@ export default (
|
||||
const paramName = key.name;
|
||||
nextResult[paramName] = matchResult;
|
||||
return nextResult;
|
||||
},
|
||||
queryParams,
|
||||
);
|
||||
}, queryParams);
|
||||
|
||||
return NavigationActions.navigate({
|
||||
routeName: matchedRouteName,
|
||||
@@ -404,7 +400,7 @@ export default (
|
||||
|
||||
getScreenOptions: createConfigGetter(
|
||||
routeConfigs,
|
||||
stackConfig.navigationOptions,
|
||||
stackConfig.navigationOptions
|
||||
),
|
||||
|
||||
getScreenConfig: getScreenConfigDeprecated,
|
||||
|
||||
Reference in New Issue
Block a user