Skip to content

Commit 1031539

Browse files
committed
Merge pull request #192 from dariocravero/normalise-redux-shape
Normalised `reduxShape` in `components`
2 parents 3a54f76 + 0b08878 commit 1031539

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

src/components/createConnector.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import createReduxShape from './createReduxShape';
12
import identity from '../utils/identity';
23
import shallowEqual from '../utils/shallowEqual';
34
import isPlainObject from '../utils/isPlainObject';
@@ -8,7 +9,7 @@ export default function createConnector(React) {
89

910
return class Connector extends Component {
1011
static contextTypes = {
11-
redux: PropTypes.object.isRequired
12+
redux: createReduxShape(PropTypes).isRequired
1213
};
1314

1415
static propTypes = {

src/components/createProvider.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1+
import createReduxShape from './createReduxShape';
2+
13
export default function createProvider(React) {
24
const { Component, PropTypes } = React;
35

4-
const reduxShape = PropTypes.shape({
5-
subscribe: PropTypes.func.isRequired,
6-
dispatch: PropTypes.func.isRequired,
7-
getState: PropTypes.func.isRequired
8-
});
6+
const reduxShapeIsRequired = createReduxShape(PropTypes).isRequired;
97

108
return class Provider extends Component {
119
static propTypes = {
12-
redux: reduxShape.isRequired,
10+
redux: reduxShapeIsRequired,
1311
children: PropTypes.func.isRequired
1412
};
1513

1614
static childContextTypes = {
17-
redux: reduxShape.isRequired
15+
redux: reduxShapeIsRequired
1816
};
1917

2018
getChildContext() {

src/components/createReduxShape.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function createReduxShape(PropTypes) {
2+
return PropTypes.shape({
3+
subscribe: PropTypes.func.isRequired,
4+
dispatch: PropTypes.func.isRequired,
5+
getState: PropTypes.func.isRequired
6+
});
7+
}

0 commit comments

Comments
 (0)