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

Update url.pushTo and url.replaceTo update only on dev. (#434)

In order to warn the user, now we are using a warn function
which is located in the lib/utils module.
This commit is contained in:
Arunoda Susiripala 2016-12-20 02:34:38 +05:30 committed by Guillermo Rauch
parent ff7e128c80
commit 565bb5790b
3 changed files with 10 additions and 5 deletions

View file

@ -1,5 +1,6 @@
import React, { Component, PropTypes } from 'react' import React, { Component, PropTypes } from 'react'
import { AppContainer } from 'react-hot-loader' import { AppContainer } from 'react-hot-loader'
import { warn } from './utils'
export default class App extends Component { export default class App extends Component {
static childContextTypes = { static childContextTypes = {
@ -67,7 +68,7 @@ function propsToState (props) {
back: () => router.back(), back: () => router.back(),
push: (url, as) => router.push(url, as), push: (url, as) => router.push(url, as),
pushTo: (href, as) => { pushTo: (href, as) => {
console.warn(`Warning: 'url.pushTo()' is deprecated. Please use 'url.push()' instead.`) warn(`Warning: 'url.pushTo()' is deprecated. Please use 'url.push()' instead.`)
const pushRoute = as ? href : null const pushRoute = as ? href : null
const pushUrl = as || href const pushUrl = as || href
@ -75,7 +76,7 @@ function propsToState (props) {
}, },
replace: (url, as) => router.replace(url, as), replace: (url, as) => router.replace(url, as),
replaceTo: (href, as) => { replaceTo: (href, as) => {
console.warn(`Warning: 'url.replaceTo()' is deprecated. Please use 'url.replace()' instead.`) warn(`Warning: 'url.replaceTo()' is deprecated. Please use 'url.replace()' instead.`)
const replaceRoute = as ? href : null const replaceRoute = as ? href : null
const replaceUrl = as || href const replaceUrl = as || href

View file

@ -1,8 +1,7 @@
import { warn } from './utils'
const css = require('glamor') const css = require('glamor')
if (process.env.NODE_ENV !== 'production') { warn('Warning: \'next/css\' is deprecated. Please use styled-jsx syntax instead.')
console.error('Warning: \'next/css\' is deprecated. Please use styled-jsx syntax instead.')
}
/** /**
* Expose style as default and the whole object as properties * Expose style as default and the whole object as properties

5
lib/utils.js Normal file
View file

@ -0,0 +1,5 @@
export function warn (message) {
if (process.env.NODE_ENV !== 'production') {
console.error(message)
}
}