Skip to content

Instantly share code, notes, and snippets.

@tocttou
Last active June 19, 2017 22:53
Show Gist options
  • Save tocttou/66a7fc0e1a3a02bd3b18f5a702f820d9 to your computer and use it in GitHub Desktop.
Save tocttou/66a7fc0e1a3a02bd3b18f5a702f820d9 to your computer and use it in GitHub Desktop.
import React, { Component, PropTypes } from "react";
class SocketProvider extends Component {
constructor(props, context) {
super(props, context);
this.socket = context.socket;
}
render() {
return (
<span>
{React.cloneElement(this.props.children, {
...this.props,
...{ socket: this.socket }
})}
</span>
);
}
}
SocketProvider.contextTypes = {
socket: PropTypes.object.isRequired
};
export default SocketProvider;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment