Skip to content

Instantly share code, notes, and snippets.

@pirate
Last active December 20, 2017 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pirate/51689c0e70a3447e3dac6a2e580a176e to your computer and use it in GitHub Desktop.
Save pirate/51689c0e70a3447e3dac6a2e580a176e to your computer and use it in GitHub Desktop.
const ToggleableVideo = connect({
mapStateToProps: ({video}) => ({stream_id: video.my_stream_id}),
mapDispatchToProps: (dispatch) => ({
onStartStreaming() {
dispatch({type: 'START_STREAMING'})
},
}),
render: ({stream_id}) =>
stream_id ?
<VideoStream stream_id={stream_id}/>
: <div className="btn btn-success">
<i classNamename="fa fa-tv" style={{fontSize: 44}}/><br/>
Start Streaming
</div>
})
// The result is a normal connected react component:
<ToggleableVideo/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment