Ilya-Meer / event-point

An event tracker
0 stars 2 forks source link

Page navigation state not persisted #1

Open Ilya-Meer opened 4 years ago

Ilya-Meer commented 4 years ago

Currently if the user is navigating around the app, when the page is refreshed, they are routed back to the root / route and must navigate back to their previous destination.

One solution would be to listen to history changes and persist the destination route in local storage. Then, when the page is refreshed, we fetch that information from local storage and navigate the app to that route.

fabionl commented 4 years ago

Hmmm... I'm still setting it up here, so couldn't test yet. Shouldn't React load the proper component from the URL?

Ilya-Meer commented 4 years ago

That's a great point, I believe it should work like this, too. What's supposed to be happening here is the "Catch-all" solution described in this thread. As soon as we refresh, we get back the application.html.erb with the JS bundle that should take over and render the proper component for the URL, just as you say.

For some reason, that's not happening. I suspect that it has to do with an improper server-side routing configuration. Namely, these two lines:

  root 'pages#index'
  get '*path', to: 'pages#index', via: :all