forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure props.url is immutable (vercel#4352)
* Make sure props.url is immutable * Add test for immutable url * Match object instead of string
- Loading branch information
1 parent
5b20f32
commit 44d3b19
Showing
4 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
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 | ||
} | ||
} | ||
|
||
componentWillReceiveProps (nextProps) { | ||
this.setState(() => { | ||
return { | ||
previousUrl: this.props.url, | ||
url: nextProps.url | ||
} | ||
}) | ||
} | ||
|
||
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> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters