Last active
June 19, 2017 22:53
-
-
Save tocttou/66a7fc0e1a3a02bd3b18f5a702f820d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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