Skip to content

Commit 1e333a0

Browse files
committed
Update url.pushTo and url.replaceTo update only on dev.
In order to warn the user, now we are using a warn function which is located in the lib/utils module.
1 parent e45cc89 commit 1e333a0

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

lib/app.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { Component, PropTypes } from 'react'
22
import { AppContainer } from 'react-hot-loader'
3+
import { warn } from './utils'
34

45
export default class App extends Component {
56
static childContextTypes = {
@@ -67,15 +68,15 @@ function propsToState (props) {
6768
back: () => router.back(),
6869
push: (url, as) => router.push(url, as),
6970
pushTo: (href, as) => {
70-
console.warn(`Warning: 'url.pushTo()' is deprecated. Please use 'url.push()' instead.`)
71+
warn(`Warning: 'url.pushTo()' is deprecated. Please use 'url.push()' instead.`)
7172
const pushRoute = as ? href : null
7273
const pushUrl = as || href
7374

7475
return router.push(pushRoute, pushUrl)
7576
},
7677
replace: (url, as) => router.replace(url, as),
7778
replaceTo: (href, as) => {
78-
console.warn(`Warning: 'url.replaceTo()' is deprecated. Please use 'url.replace()' instead.`)
79+
warn(`Warning: 'url.replaceTo()' is deprecated. Please use 'url.replace()' instead.`)
7980
const replaceRoute = as ? href : null
8081
const replaceUrl = as || href
8182

lib/css.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
import { warn } from './utils'
12
const css = require('glamor')
23

3-
if (process.env.NODE_ENV !== 'production') {
4-
console.error('Warning: \'next/css\' is deprecated. Please use styled-jsx syntax instead.')
5-
}
4+
warn('Warning: \'next/css\' is deprecated. Please use styled-jsx syntax instead.')
65

76
/**
87
* Expose style as default and the whole object as properties

lib/utils.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export function warn (message) {
2+
if (process.env.NODE_ENV !== 'production') {
3+
console.error(message)
4+
}
5+
}

0 commit comments

Comments
 (0)