Skip to content

Commit 441c359

Browse files
committed
Merge pull request #135 from mattydoincode/master
ie8 Support by alternative method for adding static properties
2 parents e2c7746 + ef14a40 commit 441c359

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

src/components/createConnect.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,6 @@ export default function createConnect(React) {
7878

7979
return function wrapWithConnect(WrappedComponent) {
8080
class Connect extends Component {
81-
static displayName = `Connect(${getDisplayName(WrappedComponent)})`;
82-
static WrappedComponent = WrappedComponent;
83-
84-
static contextTypes = {
85-
store: storeShape
86-
};
87-
88-
static propTypes = {
89-
store: storeShape
90-
};
9181

9282
shouldComponentUpdate(nextProps, nextState) {
9383
if (!pure) {
@@ -215,6 +205,17 @@ export default function createConnect(React) {
215205
);
216206
}
217207
}
208+
// adding properties in this way
209+
// prevents ie8 from breaking
210+
Connect.displayName = `Connect(${getDisplayName(WrappedComponent)})`;
211+
Connect.WrappedComponent = WrappedComponent;
212+
213+
Connect.contextTypes = {
214+
store: storeShape
215+
};
216+
Connect.propTypes = {
217+
store: storeShape
218+
};
218219

219220
if (process.env.NODE_ENV !== 'production') {
220221
Connect.prototype.componentWillUpdate = function componentWillUpdate() {

src/components/createProvider.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,7 @@ export default function createProvider(React) {
5959
);
6060
}
6161

62-
return class Provider extends Component {
63-
static childContextTypes = {
64-
store: storeShape.isRequired
65-
};
66-
67-
static propTypes = {
68-
store: storeShape.isRequired,
69-
children: (requireFunctionChild ?
70-
PropTypes.func :
71-
PropTypes.element
72-
).isRequired
73-
};
62+
class Provider extends Component {
7463

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

10392
return Children.only(children);
10493
}
94+
}
95+
// adding properties in this way
96+
// prevents ie8 from breaking
97+
Provider.childContextTypes = {
98+
store: storeShape.isRequired
99+
};
100+
101+
Provider.propTypes = {
102+
store: storeShape.isRequired,
103+
children: (requireFunctionChild ?
104+
PropTypes.func :
105+
PropTypes.element
106+
).isRequired
105107
};
108+
return Provider;
106109
}

0 commit comments

Comments
 (0)