Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion lib/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component, PropTypes } from 'react'
import { AppContainer } from 'react-hot-loader'
import shallowEquals from './shallow-equals'
import { warn } from './utils'

const ErrorDebug = process.env.NODE_ENV === 'production'
? null : require('./error-debug').default
Expand Down Expand Up @@ -65,6 +66,32 @@ class Container extends Component {
function createUrl (router) {
return {
query: router.query,
pathname: router.pathname
pathname: router.pathname,
back: () => {
warn(`Warning: 'url.back()' is deprecated. Use "window.history.back()"`)
router.back()
},
push: (url, as) => {
warn(`Warning: 'url.push()' is deprecated. Use "next/router" APIs.`)
return router.push(url, as)
},
pushTo: (href, as) => {
warn(`Warning: 'url.pushTo()' is deprecated. Use "next/router" APIs.`)
const pushRoute = as ? href : null
const pushUrl = as || href

return router.push(pushRoute, pushUrl)
},
replace: (url, as) => {
warn(`Warning: 'url.replace()' is deprecated. Use "next/router" APIs.`)
return router.replace(url, as)
},
replaceTo: (href, as) => {
warn(`Warning: 'url.replaceTo()' is deprecated. Use "next/router" APIs.`)
const replaceRoute = as ? href : null
const replaceUrl = as || href

return router.replace(replaceRoute, replaceUrl)
}
}
}
4 changes: 2 additions & 2 deletions test/integration/basic/test/client-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export default (context, render) => {
})

describe('with shallow routing', () => {
it('should not update the url without running getInitialProps', async () => {
it('should update the url without running getInitialProps', async () => {
const browser = await webdriver(context.appPort, '/nav/shallow-routing')
const counter = await browser
.elementByCss('#increase').click()
Expand All @@ -196,7 +196,7 @@ export default (context, render) => {
await browser.close()
})

it('should handle back button and should not run getInitialProps', async () => {
it('should handle the back button and should not run getInitialProps', async () => {
const browser = await webdriver(context.appPort, '/nav/shallow-routing')
let counter = await browser
.elementByCss('#increase').click()
Expand Down