Skip to content

Instantly share code, notes, and snippets.

@allindeveloper
Created July 1, 2019 13:02
Show Gist options
  • Select an option

  • Save allindeveloper/bba19fa3c9253b8949e88951e717078c to your computer and use it in GitHub Desktop.

Select an option

Save allindeveloper/bba19fa3c9253b8949e88951e717078c to your computer and use it in GitHub Desktop.
import React from 'react';
class Input extends React.Component {
onSubmit(event) {
event.preventDefault();
const strSeconds = this.refs.seconds.value;
if(strSeconds.match(/[0-9]/)) {
this.refs.seconds.value = '';
this.props.onSetCountdown(parseInt(strSeconds, 10));
}
}
render() {
return (
<form ref="form" onSubmit={this.onSubmit.bind(this)}>
<input type="text" ref="seconds" placeholder="enter time in seconds"/>
<input type="submit" value="Start"></input>
</form>
)
}
}
export default Input;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment