Skip to content

Commit cf6971a

Browse files
committed
Use instance property instead of state
1 parent 6b70f85 commit cf6971a

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

modules/mixins/LocationContext.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,6 @@ var LocationContext = {
3737
};
3838
},
3939

40-
getInitialState: function () {
41-
var location = this.props.location;
42-
43-
if (typeof location === 'string')
44-
location = NAMED_LOCATIONS[location];
45-
46-
// Automatically fall back to full page refreshes in
47-
// browsers that do not support HTML5 history.
48-
if (location === HistoryLocation && !supportsHistory())
49-
location = RefreshLocation;
50-
51-
return {
52-
location: location
53-
};
54-
},
55-
5640
componentWillMount: function () {
5741
var location = this.getLocation();
5842

@@ -63,7 +47,9 @@ var LocationContext = {
6347

6448
if (location) {
6549
PathStore.setup(location);
66-
this.handlePathChange();
50+
51+
if (this.updateLocation)
52+
this.updateLocation(PathStore.getCurrentPath(), PathStore.getCurrentActionType());
6753
}
6854
},
6955

@@ -86,7 +72,21 @@ var LocationContext = {
8672
* Returns the location object this component uses.
8773
*/
8874
getLocation: function () {
89-
return this.state.location;
75+
if (this._location == null) {
76+
var location = this.props.location;
77+
78+
if (typeof location === 'string')
79+
location = NAMED_LOCATIONS[location];
80+
81+
// Automatically fall back to full page refreshes in
82+
// browsers that do not support HTML5 history.
83+
if (location === HistoryLocation && !supportsHistory())
84+
location = RefreshLocation;
85+
86+
this._location = location;
87+
}
88+
89+
return this._location;
9090
},
9191

9292
childContextTypes: {

0 commit comments

Comments
 (0)