Last active
May 6, 2017 06:26
-
-
Save yashikagarg13/0dbd4d921f8ffce8aba168cd7402469d to your computer and use it in GitHub Desktop.
Jest Blog
This file contains 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
class Form extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
input: "", | |
}; | |
this.onChangeHandler = this.onChangeHandler.bind(this); | |
this.onSubmitHandler = this.onSubmitHandler.bind(this); | |
} | |
onChangeHandler(event) { | |
this.setState({ | |
input: event.target.value | |
}); | |
} | |
onSubmitHandler(event) { | |
Axios.post("some_url", {data: this.state.input}) | |
.then(response => { | |
AlertsHelper.show({ | |
type: "success", | |
message: response.message, | |
}); | |
}) | |
.catch(error => { | |
AlertsHelper.show({ | |
type: "error", | |
message: error.message, | |
}); | |
}); | |
} | |
render () { | |
return ( | |
<form onSubmit={this.onSubmitHandler}> | |
<input type=“text” onChange={this.onChangeHandler} /> | |
<button type=“submit”>Submit</button> | |
</form> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment