Skip to content

Commit 61d9fa2

Browse files
committed
Merge pull request #12 from ooflorent/wrap-context
Reduce context footprint
2 parents 059f4dd + ff74aad commit 61d9fa2

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/Container.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import identity from 'lodash/utility/identity';
44

55
export default class ReduxContainer extends Component {
66
static contextTypes = {
7-
wrapActionCreator: PropTypes.func.isRequired,
8-
observeStores: PropTypes.func.isRequired
7+
redux: PropTypes.object.isRequired
98
};
109

1110
static propTypes = {
@@ -38,7 +37,7 @@ export default class ReduxContainer extends Component {
3837
}
3938

4039
update(props) {
41-
this.actions = mapValues(props.actions, this.context.wrapActionCreator);
40+
this.actions = mapValues(props.actions, this.context.redux.wrapActionCreator);
4241
if (this.unsubscribe) {
4342
this.unsubscribe();
4443
}
@@ -52,7 +51,7 @@ export default class ReduxContainer extends Component {
5251
}
5352

5453
this.mapState = mapState;
55-
this.unsubscribe = this.context.observeStores(stores, this.handleChange);
54+
this.unsubscribe = this.context.redux.observeStores(stores, this.handleChange);
5655
}
5756

5857
handleChange(stateFromStores) {

src/Root.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ import createDispatcher from './createDispatcher';
44
export default function root(DecoratedComponent) {
55
return class ReduxRoot extends Component {
66
static childContextTypes = {
7-
observeStores: PropTypes.func.isRequired,
8-
wrapActionCreator: PropTypes.func.isRequired
7+
redux: PropTypes.object.isRequired
98
};
109

1110
getChildContext() {
11+
const { observeStores, wrapActionCreator } = this.dispatcher
1212
return {
13-
observeStores: this.dispatcher.observeStores,
14-
wrapActionCreator: this.dispatcher.wrapActionCreator
13+
redux: {
14+
observeStores,
15+
wrapActionCreator
16+
}
1517
};
1618
}
1719

0 commit comments

Comments
 (0)