|
1 | 1 | import React, { Component, PropTypes } from 'react'
|
2 | 2 | import { AppContainer } from 'react-hot-loader'
|
3 | 3 | import shallowEquals from './shallow-equals'
|
| 4 | +import { warn } from './utils' |
4 | 5 |
|
5 | 6 | const ErrorDebug = process.env.NODE_ENV === 'production'
|
6 | 7 | ? null : require('./error-debug').default
|
@@ -65,6 +66,32 @@ class Container extends Component {
|
65 | 66 | function createUrl (router) {
|
66 | 67 | return {
|
67 | 68 | query: router.query,
|
68 |
| - pathname: router.pathname |
| 69 | + pathname: router.pathname, |
| 70 | + back: () => { |
| 71 | + warn(`Warning: 'url.back()' is deprecated. Use "window.history.back()"`) |
| 72 | + router.back() |
| 73 | + }, |
| 74 | + push: (url, as) => { |
| 75 | + warn(`Warning: 'url.push()' is deprecated. Use "next/router" APIs.`) |
| 76 | + return router.push(url, as) |
| 77 | + }, |
| 78 | + pushTo: (href, as) => { |
| 79 | + warn(`Warning: 'url.pushTo()' is deprecated. Use "next/router" APIs.`) |
| 80 | + const pushRoute = as ? href : null |
| 81 | + const pushUrl = as || href |
| 82 | + |
| 83 | + return router.push(pushRoute, pushUrl) |
| 84 | + }, |
| 85 | + replace: (url, as) => { |
| 86 | + warn(`Warning: 'url.replace()' is deprecated. Use "next/router" APIs.`) |
| 87 | + return router.replace(url, as) |
| 88 | + }, |
| 89 | + replaceTo: (href, as) => { |
| 90 | + warn(`Warning: 'url.replaceTo()' is deprecated. Use "next/router" APIs.`) |
| 91 | + const replaceRoute = as ? href : null |
| 92 | + const replaceUrl = as || href |
| 93 | + |
| 94 | + return router.replace(replaceRoute, replaceUrl) |
| 95 | + } |
69 | 96 | }
|
70 | 97 | }
|
0 commit comments