reactive-python/reactpy-router

Back Button Does Not Work

rmorshea opened this issue · 3 comments

Right now, if you click the browser's back button, the page does not update. We need to subscribe to changes in browser history and send them to the sever. I'm not really sure how best to achieve this in the long run. In the short run, I think this may require creating a hidden JS component that we display at the level of the router that does this.

There's also the additional complexity of: What happens if the user presses the back button enough to where they're not on a page that uses reactpy-router anymore?

We don't want to globally intercept all page changes. We only want to intercept page changes that can be resolved by an existing router node.

What happens if the user presses the back button enough to where they're not on a page that uses reactpy-router anymore?

That's handled with an effect cleanup in an invisible element that's rendered as part of the router.

We only want to intercept page changes that can be resolved by an existing router node.

I'm not really sure I understand this one. How would one know a priori whether a given location could be evaluated by a router node without checking? Besides, if no route matches, then the router just renders None which seems like the desired behavior.

It's possible to record whether the URL was successfully evaluated as a data attribute within the invisible element. But if the effect cleanup is able to handle edge cases on it's own then this is likely not needed.