Created
July 1, 2019 13:02
-
-
Save allindeveloper/bba19fa3c9253b8949e88951e717078c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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