Skip to content

Instantly share code, notes, and snippets.

@frankfaustino
Last active March 28, 2018 16:19
Show Gist options
  • Save frankfaustino/d443b56242454d3ce35acc037f4e0d5f to your computer and use it in GitHub Desktop.
Save frankfaustino/d443b56242454d3ce35acc037f4e0d5f to your computer and use it in GitHub Desktop.
React Router V4 Redirect after form submission
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