Skip to content

Commit

Permalink
Merge pull request reduxjs#192 from dariocravero/normalise-redux-shape
Browse files Browse the repository at this point in the history
Normalised `reduxShape` in `components`
  • Loading branch information
gaearon committed Jun 29, 2015
2 parents 3a54f76 + 0b08878 commit 1031539
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/components/createConnector.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import createReduxShape from './createReduxShape';
import identity from '../utils/identity';
import shallowEqual from '../utils/shallowEqual';
import isPlainObject from '../utils/isPlainObject';
Expand All @@ -8,7 +9,7 @@ export default function createConnector(React) {

return class Connector extends Component {
static contextTypes = {
redux: PropTypes.object.isRequired
redux: createReduxShape(PropTypes).isRequired
};

static propTypes = {
Expand Down
12 changes: 5 additions & 7 deletions src/components/createProvider.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import createReduxShape from './createReduxShape';

export default function createProvider(React) {
const { Component, PropTypes } = React;

const reduxShape = PropTypes.shape({
subscribe: PropTypes.func.isRequired,
dispatch: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired
});
const reduxShapeIsRequired = createReduxShape(PropTypes).isRequired;

return class Provider extends Component {
static propTypes = {
redux: reduxShape.isRequired,
redux: reduxShapeIsRequired,
children: PropTypes.func.isRequired
};

static childContextTypes = {
redux: reduxShape.isRequired
redux: reduxShapeIsRequired
};

getChildContext() {
Expand Down
7 changes: 7 additions & 0 deletions src/components/createReduxShape.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function createReduxShape(PropTypes) {
return PropTypes.shape({
subscribe: PropTypes.func.isRequired,
dispatch: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired
});
}

0 comments on commit 1031539

Please sign in to comment.