function connect(C) {
return class ConnectedComponent extends React.Component {
componentWillMount() {
this.unsubscribe = this.context.store.subscribe(state => this.setState(state));
}
componentWillUnmount() {
this.unsubscribe();
}
render() {
return <C {...this.props} {...this.state}} />;
}
};
}