question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Retain state while refreshing

See original GitHub issue

I’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:open
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
makenosoundcommented, Sep 1, 2020

you’d like the current data to be displayed until the fetch has completed?

That is correct, yep. A “stale while revalidate” if you will.

0reactions
makenosoundcommented, Sep 1, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found