From de6521a481d4c4cd072cd0c1620cc259725e8abd Mon Sep 17 00:00:00 2001 From: Thomas Jaggi <thomas.jaggi@gmail.com> Date: Sat, 17 Dec 2016 21:18:50 +0100 Subject: [PATCH] Allow for custom route in pushTo and replaceTo methods (#417) --- lib/app.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/app.js b/lib/app.js index 3aee5e3aa8949..e0fcd43b65add 100644 --- a/lib/app.js +++ b/lib/app.js @@ -67,9 +67,19 @@ function propsToState (props) { pathname: router.pathname, back: () => router.back(), push: (url) => router.push(route, url), - pushTo: (url) => router.push(null, url), + pushTo: (href, as) => { + const pushRoute = as ? href : null + const pushUrl = as || href + + return router.push(pushRoute, pushUrl) + }, replace: (url) => router.replace(route, url), - replaceTo: (url) => router.replace(null, url) + replaceTo: (href, as) => { + const replaceRoute = as ? href : null + const replaceUrl = as || href + + return router.replace(replaceRoute, replaceUrl) + } } return {