Skip to content

Commit 2c90d04

Browse files
committed
Update given feedback on when to call createParams
1 parent a81788b commit 2c90d04

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

modules/matchRoutes.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,27 @@ import { createRoutes } from './RouteUtils'
55
import { canUseMembrane } from './deprecateObjectProperties'
66
import deprecateLocationProperties from './deprecateLocationProperties'
77

8-
function getChildRoutes(route, progressState, callback) {
8+
function getChildRoutes(route, location, paramNames, paramValues, remainingPathname, callback) {
99
if (route.childRoutes) {
1010
return [ null, route.childRoutes ]
1111
}
1212
if (!route.getChildRoutes) {
1313
return []
1414
}
1515

16-
let sync = true, result
16+
let sync = true, result, progressStateWithLocation
17+
const progressState = {
18+
params: createParams(paramNames, paramValues),
19+
remainingPathname
20+
}
21+
22+
if (__DEV__ && canUseMembrane) {
23+
progressStateWithLocation = deprecateLocationProperties(progressState, location)
24+
} else {
25+
progressStateWithLocation = { ...progressState, ...location }
26+
}
1727

18-
route.getChildRoutes(progressState, function (error, childRoutes) {
28+
route.getChildRoutes(progressStateWithLocation, function (error, childRoutes) {
1929
childRoutes = !error && createRoutes(childRoutes)
2030
if (sync) {
2131
result = [ error, childRoutes ]
@@ -162,19 +172,7 @@ function matchRouteDeep(
162172
}
163173
}
164174

165-
const progressState = {
166-
params: createParams(paramNames, paramValues),
167-
remainingPathname
168-
}
169-
let progressStateWithLocation
170-
171-
if (__DEV__ && canUseMembrane) {
172-
progressStateWithLocation = deprecateLocationProperties(progressState, location)
173-
} else {
174-
progressStateWithLocation = { ...progressState, ...location }
175-
}
176-
177-
const result = getChildRoutes(route, progressStateWithLocation, onChildRoutes)
175+
const result = getChildRoutes(route, location, paramNames, paramValues, remainingPathname, onChildRoutes)
178176
if (result) {
179177
onChildRoutes(...result)
180178
}

0 commit comments

Comments
 (0)