Skip to content

Commit 38b5d92

Browse files
committed
Use initialActiveRoutes/Params/Query instead of initialActiveState
1 parent 41149ab commit 38b5d92

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

modules/mixins/ActiveContext.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,24 @@ function queryIsActive(activeQuery, query) {
3030
var ActiveContext = {
3131

3232
propTypes: {
33-
initialActiveState: React.PropTypes.object
33+
initialActiveRoutes: React.PropTypes.array.isRequired,
34+
initialActiveParams: React.PropTypes.object.isRequired,
35+
initialActiveQuery: React.PropTypes.object.isRequired
3436
},
3537

3638
getDefaultProps: function () {
3739
return {
38-
initialActiveState: {}
40+
initialActiveRoutes: [],
41+
initialActiveParams: {},
42+
initialActiveQuery: {}
3943
};
4044
},
4145

4246
getInitialState: function () {
43-
var state = this.props.initialActiveState;
44-
4547
return {
46-
activeRoutes: state.activeRoutes || [],
47-
activeParams: state.activeParams || {},
48-
activeQuery: state.activeQuery || {}
48+
activeRoutes: this.props.initialActiveRoutes,
49+
activeParams: this.props.initialActiveParams,
50+
activeQuery: this.props.initialActiveQuery
4951
};
5052
},
5153

modules/mixins/__tests__/ActiveContext-test.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ describe('ActiveContext', function () {
2424
beforeEach(function () {
2525
component = ReactTestUtils.renderIntoDocument(
2626
App({
27-
initialActiveState: {
28-
activeRoutes: [ route ]
29-
}
27+
initialActiveRoutes: [ route ]
3028
})
3129
);
3230
});
@@ -45,11 +43,9 @@ describe('ActiveContext', function () {
4543
beforeEach(function () {
4644
component = ReactTestUtils.renderIntoDocument(
4745
App({
48-
initialActiveState: {
49-
activeRoutes: [ route ],
50-
activeParams: { id: '123', show: 'true', variant: 456 },
51-
activeQuery: { search: 'abc', limit: 789 }
52-
}
46+
initialActiveRoutes: [ route ],
47+
initialActiveParams: { id: '123', show: 'true', variant: 456 },
48+
initialActiveQuery: { search: 'abc', limit: 789 }
5349
})
5450
);
5551
});
@@ -82,10 +78,8 @@ describe('ActiveContext', function () {
8278
beforeEach(function () {
8379
component = ReactTestUtils.renderIntoDocument(
8480
App({
85-
initialActiveState: {
86-
activeRoutes: [ route ],
87-
activeParams: { id: 123 }
88-
}
81+
initialActiveRoutes: [ route ],
82+
initialActiveParams: { id: 123 }
8983
})
9084
);
9185
});

0 commit comments

Comments
 (0)