Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Website crashing when you refresh results or details page #92

Open
georgiamshaw opened this issue Oct 16, 2019 · 4 comments
Open

Website crashing when you refresh results or details page #92

georgiamshaw opened this issue Oct 16, 2019 · 4 comments
Labels
bug Something isn't working important 1

Comments

@georgiamshaw
Copy link
Collaborator

georgiamshaw commented Oct 16, 2019

I enter a postcode and get my results on the results page. If I refresh this, the page still displays but my results have gone (this is on localhost).

Screenshot 2019-10-16 at 10 56 08

@georgiamshaw georgiamshaw added bug Something isn't working important 1 labels Oct 16, 2019
@gminova
Copy link
Member

gminova commented Oct 16, 2019

This is what happens on our deployed website:

1refresh404-details-page
1refresh404-results-page

However in browser forward/back buttons works correctly, and all airtable data is still reachable at endpoint: https://generation-change.netlify.com/.netlify/functions/getdata

@georgiamshaw
Copy link
Collaborator Author

georgiamshaw commented Oct 16, 2019

What we think is happening is the state gets lost.

Solutions we have been thinking of trying are storing our data in local storage, looking into using the useContext hook, or looking into netlify redirects.

Any suggestions welcome!

@maxgerber
Copy link

You're right — as React is a front-end framework your state will not persist between sessions unless you set something up to capture it.

AFAIK useContext will give you the same problem. I'd recommend using the sessionStorage API, which works much like localStorage. However, sessionStorage will only persist so long as your browser is open (including when you refresh), and will delete every time you close your browser.

https://www.robinwieruch.de/local-storage-react

@samjam48
Copy link
Collaborator

we could just use more of the router capabilities instead of relying on state and session storage so when you reload the url it works it our from the url.
e.g. {site-name}/details/{project_id}

But if we are keeping all the airtable data in our state as well then it would mean we have to do more specific calls to airtable on every different page or still use session storage for the airtable data...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working important 1
Projects
None yet
Development

No branches or pull requests

4 participants