Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show deprecate url.pushTo and url.replaceTo warnings only on dev. #434

Merged
merged 1 commit into from
Dec 19, 2016
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
5 changes: 3 additions & 2 deletions lib/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component, PropTypes } from 'react'
import { AppContainer } from 'react-hot-loader'
import { warn } from './utils'

export default class App extends Component {
static childContextTypes = {
Expand Down Expand Up @@ -67,15 +68,15 @@ function propsToState (props) {
back: () => router.back(),
push: (url, as) => router.push(url, 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 pushUrl = as || href

return router.push(pushRoute, pushUrl)
},
replace: (url, as) => router.replace(url, 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 replaceUrl = as || href

Expand Down
5 changes: 2 additions & 3 deletions lib/css.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { warn } from './utils'
const css = require('glamor')

if (process.env.NODE_ENV !== 'production') {
console.error('Warning: \'next/css\' is deprecated. Please use styled-jsx syntax instead.')
}
warn('Warning: \'next/css\' is deprecated. Please use styled-jsx syntax instead.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once we have the wiki page up for glamor, we can link directly to it from here, instead of this half-baked suggestion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.


/**
* Expose style as default and the whole object as properties
Expand Down
5 changes: 5 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function warn (message) {
if (process.env.NODE_ENV !== 'production') {
console.error(message)
}
}