mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Run manual-bind-to-arrow codemod (#4906)
https://github.com/reactjs/react-codemod#manual-bind-to-arrow
This commit is contained in:
parent
83970c908d
commit
4c602ff395
|
@ -10,7 +10,6 @@ import { warn, execOnce, getLocationOrigin } from './utils'
|
|||
export default class Link extends Component {
|
||||
constructor (props, ...rest) {
|
||||
super(props, ...rest)
|
||||
this.linkClicked = this.linkClicked.bind(this)
|
||||
this.formatUrls(props)
|
||||
}
|
||||
|
||||
|
@ -40,7 +39,7 @@ export default class Link extends Component {
|
|||
this.formatUrls(nextProps)
|
||||
}
|
||||
|
||||
linkClicked (e) {
|
||||
linkClicked = e => {
|
||||
const { nodeName, target } = e.currentTarget
|
||||
if (nodeName === 'A' &&
|
||||
((target && target !== '_self') || e.metaKey || e.ctrlKey || e.shiftKey || (e.nativeEvent && e.nativeEvent.which === 2))) {
|
||||
|
@ -84,7 +83,7 @@ export default class Link extends Component {
|
|||
.catch((err) => {
|
||||
if (this.props.onError) this.props.onError(err)
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
prefetch () {
|
||||
if (!this.props.prefetch) return
|
||||
|
|
|
@ -44,7 +44,6 @@ export default class Router {
|
|||
this.asPath = as
|
||||
this.subscriptions = new Set()
|
||||
this.componentLoadCancel = null
|
||||
this.onPopState = this.onPopState.bind(this)
|
||||
this._beforePopState = () => true
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
|
@ -56,7 +55,7 @@ export default class Router {
|
|||
}
|
||||
}
|
||||
|
||||
onPopState (e) {
|
||||
onPopState = e => {
|
||||
if (!e.state) {
|
||||
// We get state as undefined for two reasons.
|
||||
// 1. With older safari (< 8) and older chrome (< 34)
|
||||
|
@ -80,7 +79,7 @@ export default class Router {
|
|||
|
||||
const { url, as, options } = e.state
|
||||
this.replace(url, as, options)
|
||||
}
|
||||
};
|
||||
|
||||
update (route, Component) {
|
||||
const data = this.components[route]
|
||||
|
|
|
@ -16,10 +16,6 @@ class HeaderNav extends React.Component {
|
|||
activeURLTopLevelRouterDeprecatedBehavior: router.asPath,
|
||||
activeURLTopLevelRouter: router.asPath
|
||||
}
|
||||
|
||||
this.handleRouteChange = this.handleRouteChange.bind(this)
|
||||
this.handleRouteChangeTopLevelRouter = this.handleRouteChangeTopLevelRouter.bind(this)
|
||||
this.handleRouteChangeTopLevelRouterDeprecatedBehavior = this.handleRouteChangeTopLevelRouterDeprecatedBehavior.bind(this)
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
|
@ -34,23 +30,23 @@ class HeaderNav extends React.Component {
|
|||
this.props.router.events.off('routeChangeComplete', this.handleRouteChange)
|
||||
}
|
||||
|
||||
handleRouteChangeTopLevelRouterDeprecatedBehavior (url) {
|
||||
handleRouteChangeTopLevelRouterDeprecatedBehavior = url => {
|
||||
this.setState({
|
||||
activeURLTopLevelRouterDeprecatedBehavior: url
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
handleRouteChangeTopLevelRouter (url) {
|
||||
handleRouteChangeTopLevelRouter = url => {
|
||||
this.setState({
|
||||
activeURLTopLevelRouter: url
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
handleRouteChange (url) {
|
||||
handleRouteChange = url => {
|
||||
this.setState({
|
||||
activeURL: url
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
render () {
|
||||
return (
|
||||
|
|
Loading…
Reference in a new issue