Pythonidaer / reddie

React app for saving and retrieving Reddit comments.
0 stars 1 forks source link

HomeScreen and DynamicPostScreen pages crash #1

Closed Pythonidaer closed 1 year ago

Pythonidaer commented 1 year ago

This happens when, for example, you are on a /dynamicPost/:id route and try to refresh the page. The data is not persistent, so the refresh results in a white screen. If you try to go back a page to the home page, it will also be white, and you will have to refresh the page for the proper HomeScreen to appear again.

To replicate:

ChatGPT had mentioned , but ChatGPT only uses react-router-dom v5 syntax and the method I found for did not work either.

I think to solve this, we need to figure out what conditions are being met logically for this to occur. When that happens, if we can catch it then we should be able to re-direct users to the homepage. Maybe we should cache the data or otherwise change the code structure another way.

Pythonidaer commented 1 year ago

Wrote code that will navigate('/') home if the DynamicPostScreen's DataContext value equals 'initial data' (the starting state value I added in App.js)