Retain state while refreshing
See original GitHub issueI’ve just started using this on a project and have a situation where I want to refresh
the data after a change. At the moment it seems like there’s no easy way to differentiate these states:
- Loading for the first time
- Reloading after the initial fetch is successful
… and I wondered if there was scope to handle that in some way. Retaining the existing value of data
would probably be enough I think (though I imagine that has flow-on effects that I am not seeing).
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
How to maintain state after a page refresh in React.js?
You can "persist" the state using local storage as Omar Suggest, but it should be done once the state ...
Read more >5 Methods to Persisting State Between Page Reloads in React
5 Methods to Persisting State Between Page Reloads in React · 1. Using LocalStorage — Class Components · 2. Using LocalStorage — Functional ......
Read more >How to Save State to LocalStorage & Persist on Refresh with ...
Step 0: Creating a new Next.js app from a demo starter · Step 1: Using React state to hide a banner on click...
Read more >Persisting state after page refresh in React Js
The simplest way to persist React state is to use the localStorage. Few third-party packages handle this for you, but they also use...
Read more >How to persist state after a page refresh in React using local ...
Sometimes it is necessary to keep the state of a React component persistent even after a browser refresh. A simple way to accomplish...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That is correct, yep. A “stale while revalidate” if you will.
Awesome, thanks! It’s definitely something that can be done around the existing API, but it adds a fair bit of boilerplate and I can seem it being a behaviour I’d want to use regularly.