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 {
|
export default class Link extends Component {
|
||||||
constructor (props, ...rest) {
|
constructor (props, ...rest) {
|
||||||
super(props, ...rest)
|
super(props, ...rest)
|
||||||
this.linkClicked = this.linkClicked.bind(this)
|
|
||||||
this.formatUrls(props)
|
this.formatUrls(props)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +39,7 @@ export default class Link extends Component {
|
||||||
this.formatUrls(nextProps)
|
this.formatUrls(nextProps)
|
||||||
}
|
}
|
||||||
|
|
||||||
linkClicked (e) {
|
linkClicked = e => {
|
||||||
const { nodeName, target } = e.currentTarget
|
const { nodeName, target } = e.currentTarget
|
||||||
if (nodeName === 'A' &&
|
if (nodeName === 'A' &&
|
||||||
((target && target !== '_self') || e.metaKey || e.ctrlKey || e.shiftKey || (e.nativeEvent && e.nativeEvent.which === 2))) {
|
((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) => {
|
.catch((err) => {
|
||||||
if (this.props.onError) this.props.onError(err)
|
if (this.props.onError) this.props.onError(err)
|
||||||
})
|
})
|
||||||
}
|
};
|
||||||
|
|
||||||
prefetch () {
|
prefetch () {
|
||||||
if (!this.props.prefetch) return
|
if (!this.props.prefetch) return
|
||||||
|
|
|
@ -44,7 +44,6 @@ export default class Router {
|
||||||
this.asPath = as
|
this.asPath = as
|
||||||
this.subscriptions = new Set()
|
this.subscriptions = new Set()
|
||||||
this.componentLoadCancel = null
|
this.componentLoadCancel = null
|
||||||
this.onPopState = this.onPopState.bind(this)
|
|
||||||
this._beforePopState = () => true
|
this._beforePopState = () => true
|
||||||
|
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
|
@ -56,7 +55,7 @@ export default class Router {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onPopState (e) {
|
onPopState = e => {
|
||||||
if (!e.state) {
|
if (!e.state) {
|
||||||
// We get state as undefined for two reasons.
|
// We get state as undefined for two reasons.
|
||||||
// 1. With older safari (< 8) and older chrome (< 34)
|
// 1. With older safari (< 8) and older chrome (< 34)
|
||||||
|
@ -80,7 +79,7 @@ export default class Router {
|
||||||
|
|
||||||
const { url, as, options } = e.state
|
const { url, as, options } = e.state
|
||||||
this.replace(url, as, options)
|
this.replace(url, as, options)
|
||||||
}
|
};
|
||||||
|
|
||||||
update (route, Component) {
|
update (route, Component) {
|
||||||
const data = this.components[route]
|
const data = this.components[route]
|
||||||
|
|
|
@ -16,10 +16,6 @@ class HeaderNav extends React.Component {
|
||||||
activeURLTopLevelRouterDeprecatedBehavior: router.asPath,
|
activeURLTopLevelRouterDeprecatedBehavior: router.asPath,
|
||||||
activeURLTopLevelRouter: router.asPath
|
activeURLTopLevelRouter: router.asPath
|
||||||
}
|
}
|
||||||
|
|
||||||
this.handleRouteChange = this.handleRouteChange.bind(this)
|
|
||||||
this.handleRouteChangeTopLevelRouter = this.handleRouteChangeTopLevelRouter.bind(this)
|
|
||||||
this.handleRouteChangeTopLevelRouterDeprecatedBehavior = this.handleRouteChangeTopLevelRouterDeprecatedBehavior.bind(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
|
@ -34,23 +30,23 @@ class HeaderNav extends React.Component {
|
||||||
this.props.router.events.off('routeChangeComplete', this.handleRouteChange)
|
this.props.router.events.off('routeChangeComplete', this.handleRouteChange)
|
||||||
}
|
}
|
||||||
|
|
||||||
handleRouteChangeTopLevelRouterDeprecatedBehavior (url) {
|
handleRouteChangeTopLevelRouterDeprecatedBehavior = url => {
|
||||||
this.setState({
|
this.setState({
|
||||||
activeURLTopLevelRouterDeprecatedBehavior: url
|
activeURLTopLevelRouterDeprecatedBehavior: url
|
||||||
})
|
})
|
||||||
}
|
};
|
||||||
|
|
||||||
handleRouteChangeTopLevelRouter (url) {
|
handleRouteChangeTopLevelRouter = url => {
|
||||||
this.setState({
|
this.setState({
|
||||||
activeURLTopLevelRouter: url
|
activeURLTopLevelRouter: url
|
||||||
})
|
})
|
||||||
}
|
};
|
||||||
|
|
||||||
handleRouteChange (url) {
|
handleRouteChange = url => {
|
||||||
this.setState({
|
this.setState({
|
||||||
activeURL: url
|
activeURL: url
|
||||||
})
|
})
|
||||||
}
|
};
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in a new issue