Last active
March 28, 2018 16:19
-
-
Save frankfaustino/d443b56242454d3ce35acc037f4e0d5f to your computer and use it in GitHub Desktop.
React Router V4 Redirect after form submission
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
import React, { Component } from 'react' | |
import { withRouter } from 'react-router-dom' | |
class ContactForm extends Component { | |
submitForm = (e) => { | |
e.preventDefault() | |
this.props.history.push('/thank-you') | |
} | |
render() { | |
return ( | |
<div> | |
<form onSubmit={this.submitForm}> | |
<button type="submit">Submit</button> | |
</form> | |
</div> | |
) | |
} | |
} | |
export default withRouter(ContactForm) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment