Skip to content

Commit 7adad61

Browse files
faceyspaceyvonovak
authored andcommitted
add 2nd params argument to StackRouter.getActionForPathAndParams (react-navigation#1623)
* add 2nd params argument to StackRouter.getActionForPathAndParams It still falls back to parsing the query string if no params argument is provided, but now TabRouter.getActionForPathAndParams which might call StackRouter.getActionForPathAndParams with a 2nd params argument will work correctly. In addition, if called directly (as may be the case in apps with custom deep-linking needs [which is my primary case]), it will function correctly without users having to build a query string. This also solves the problem that deserialization of query strings is currently implemented without support for cases like nested arrays within the query string. * Update StackRouter.js
1 parent 06cfeb5 commit 7adad61

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/routers/StackRouter.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,10 @@ export default (
323323
};
324324
},
325325

326-
getActionForPathAndParams(pathToResolve: string): ?NavigationStackAction {
326+
getActionForPathAndParams(
327+
pathToResolve: string,
328+
inputParams: ?NavigationParams
329+
): ?NavigationStackAction {
327330
// If the path is empty (null or empty string)
328331
// just return the initial route action
329332
if (!pathToResolve) {
@@ -372,9 +375,9 @@ export default (
372375

373376
// reduce the items of the query string. any query params may
374377
// be overridden by path params
375-
const queryParams = (queryString || '')
376-
.split('&')
377-
.reduce((result: *, item: string) => {
378+
const queryParams =
379+
inputParams ||
380+
(queryString || '').split('&').reduce((result: *, item: string) => {
378381
if (item !== '') {
379382
const nextResult = result || {};
380383
const [key, value] = item.split('=');

0 commit comments

Comments
 (0)