Skip to content

Instantly share code, notes, and snippets.

@hyukkwonepic
Created November 22, 2016 16:43
Show Gist options
  • Save hyukkwonepic/62e554ca39279dd7845d52074e290fd0 to your computer and use it in GitHub Desktop.
Save hyukkwonepic/62e554ca39279dd7845d52074e290fd0 to your computer and use it in GitHub Desktop.
var React = require('react');
var CountdownForm = React.createClass({
onSubmit: function (e) {
e.preventDefault();
var strSeconds = this.refs.seconds.value;
if (strSeconds.match(/^[0-9]*$/)) {
this.refs.seconds.value = '';
this.props.onSetCountdown(parseInt(strSeconds, 10));
}
},
render: function () {
return (
<div>
<form ref="form" onSubmit={this.onSubmit} className="countdown-form">
<input type="text" ref="seconds" placeholder="Enter time in seconds"/>
<button className="button expanded">Start</button>
</form>
</div>
);
}
});
module.exports = CountdownForm;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment