Search code examples
reactjsrouterreach-router

reach router back button


I have a react app with no routing but I need some kind of URL changing for my SPA.

I have a home page which takes a long time to load, and one of the items on the homepage has a click event for changing the route. Once I change routes to a "different page" (really just rendering a different component), when I hit the back button, will this reload the home page? Or does it some how stay in state and just show up immediately?

I can't build this all out without knowing this because it would be a waste of time if it can't do what I want.

I'm using reach router: https://reach.tech/router/api/Link For the replace:bool, this page says "If true, the latest entry on the history stack will be replaced with a new one. Use this when you don’t want the previous page to show up when the user clicks the back button." - This relates to what I want, but the previous page "showing up" does not say whether or not this is a fresh request.


Solution

  • It will immediately change the route. And all the components that are binded with that route will come back to its original state.