2018-05-12 18:10:17 +00:00
|
|
|
import React from 'react'
|
|
|
|
import Link from 'next/link'
|
|
|
|
|
|
|
|
export default class UrlPropChange extends React.Component {
|
|
|
|
constructor (props) {
|
|
|
|
super(props)
|
|
|
|
this.state = {
|
|
|
|
previousUrl: {},
|
|
|
|
url: props.url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-07 03:23:28 +00:00
|
|
|
// eslint-disable-next-line camelcase
|
2018-08-25 18:09:20 +00:00
|
|
|
componentDidUpdate (prevProps) {
|
|
|
|
if (prevProps.url !== this.props.url) {
|
|
|
|
this.setState(() => {
|
|
|
|
return {
|
|
|
|
previousUrl: prevProps.url,
|
|
|
|
url: this.props.url
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2018-05-12 18:10:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const {previousUrl, url} = this.state
|
|
|
|
return <div>
|
|
|
|
Current:
|
|
|
|
<div id='url-result'>
|
|
|
|
{JSON.stringify(url)}
|
|
|
|
</div>
|
|
|
|
<br /><br />
|
|
|
|
Previous:
|
|
|
|
<div id='previous-url-result'>
|
|
|
|
{JSON.stringify(previousUrl)}
|
|
|
|
</div>
|
|
|
|
<Link href='/nav/url-prop-change?added=yes'><a id='add-query'>Add querystring</a></Link>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
}
|