DEV Community

Discussion on: How can I redirect after successful post

Collapse
 
gurupal profile image
Gurupal Singh • Edited

Use BrowserRouter which uses HTML5 history API (pushState, replaceState and the popstate event) to keep your UI in sync with the URL.

After successful API request you can do

this.props.history.push("/path-to-redirect");

. Make sure to wrap your component with --> withRouter.