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:
parent
e9543cf614
commit
de6521a481
14
lib/app.js
14
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 {
|
||||
|
|
Loading…
Reference in a new issue