Skip to content

ie8 Support by alternative method for adding static properties #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}