1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Allow for custom route in pushTo and replaceTo methods (#417)

This commit is contained in:
Thomas Jaggi 2016-12-17 21:18:50 +01:00 committed by Naoyuki Kanezawa
parent e9543cf614
commit de6521a481

View file

@ -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 {