Skip to content

Commit

Permalink
Merge pull request #135 from mattydoincode/master
Browse files Browse the repository at this point in the history
ie8 Support by alternative method for adding static properties
  • Loading branch information
gaearon committed Oct 5, 2015
2 parents e2c7746 + ef14a40 commit 441c359
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
21 changes: 11 additions & 10 deletions src/components/createConnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,6 @@ export default function createConnect(React) {

return function wrapWithConnect(WrappedComponent) {
class Connect extends Component {
static displayName = `Connect(${getDisplayName(WrappedComponent)})`;
static WrappedComponent = WrappedComponent;

static contextTypes = {
store: storeShape
};

static propTypes = {
store: storeShape
};

shouldComponentUpdate(nextProps, nextState) {
if (!pure) {
Expand Down Expand Up @@ -215,6 +205,17 @@ export default function createConnect(React) {
);
}
}
// adding properties in this way
// prevents ie8 from breaking
Connect.displayName = `Connect(${getDisplayName(WrappedComponent)})`;
Connect.WrappedComponent = WrappedComponent;

Connect.contextTypes = {
store: storeShape
};
Connect.propTypes = {
store: storeShape
};

if (process.env.NODE_ENV !== 'production') {
Connect.prototype.componentWillUpdate = function componentWillUpdate() {
Expand Down
27 changes: 15 additions & 12 deletions src/components/createProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,7 @@ export default function createProvider(React) {
);
}

return class Provider extends Component {
static childContextTypes = {
store: storeShape.isRequired
};

static propTypes = {
store: storeShape.isRequired,
children: (requireFunctionChild ?
PropTypes.func :
PropTypes.element
).isRequired
};
class Provider extends Component {

getChildContext() {
return { store: this.store };
Expand Down Expand Up @@ -102,5 +91,19 @@ export default function createProvider(React) {

return Children.only(children);
}
}
// adding properties in this way
// prevents ie8 from breaking
Provider.childContextTypes = {
store: storeShape.isRequired
};

Provider.propTypes = {
store: storeShape.isRequired,
children: (requireFunctionChild ?
PropTypes.func :
PropTypes.element
).isRequired
};
return Provider;
}

0 comments on commit 441c359

Please sign in to comment.