Skip to content

Instantly share code, notes, and snippets.

@arqex
Created January 3, 2016 12:13
Show Gist options
  • Save arqex/b67b86783bfa16bad7b4 to your computer and use it in GitHub Desktop.
Save arqex/b67b86783bfa16bad7b4 to your computer and use it in GitHub Desktop.
var VideoWrapper = React.createClass({
getInitialState: function(){
return {play: false, time: '0:00:000'};
},
render: function() {
return (
<Video src="path/to/my/video.mp4"
play={ this.state.play }
onButtonClick={ () => this.setState({play: !this.state.play}) }
time={ this.state.time } />
);
},
componentDidMount: function() {
if( this.state.play ){
setTimeout( () =>
// User will create a function to add a millisecond to the
// current time, or I can ship it with my component :)
this.setState({time: addMillisecond( this.state.time )});
}, 1);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment