Skip to content

Commit ee63b33

Browse files
committed
Do not keep location in state
1 parent 1f01079 commit ee63b33

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

packages/react-router/modules/Switch.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ class Switch extends React.Component {
1515
location: PropTypes.object
1616
}
1717

18-
state = {
19-
location: this.props.location || this.context.history.location
20-
}
21-
2218
componentWillReceiveProps(nextProps) {
2319
warning(
2420
!(nextProps.location && !this.props.location),
@@ -29,15 +25,11 @@ class Switch extends React.Component {
2925
!(!nextProps.location && this.props.location),
3026
'<Switch> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.'
3127
)
32-
33-
this.setState({
34-
location: nextProps.location || this.context.history.location
35-
})
3628
}
3729

3830
render() {
3931
const { children } = this.props
40-
const { location } = this.state
32+
const location = this.props.location || this.context.history.location
4133

4234
let match, child
4335
React.Children.forEach(children, element => {

0 commit comments

Comments
 (0)