Stefan Stefan - 10 days ago 5
React JSX Question

ReactJS navigate to new location & refresh window

I use a ReactJs to create a single component, a dynamic form, after the user successfuly sends the form I need to:


  1. Redirect away from the form

  2. Full refresh of the window to get new html templates. Here I don't care for any React state. In this new location there is no React present (the component is only in one location).



So far I tried with replacing history, that caused a redirect but not a request to the server to retrieve those new html templates. How to do this?

Answer

If what I understand is correct, you want to redirect to a new page once the form is submitted. Also you want the new page to be rendered from Server Side.

Try this:

onFormSubmit() {
    // ... do things

    window.location.assign("http://exampleapp.com/somepage/");
}