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

Feature request: keep previous data #56

Open
mrfratello opened this issue Aug 15, 2024 · 2 comments
Open

Feature request: keep previous data #56

mrfratello opened this issue Aug 15, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@mrfratello
Copy link
Contributor

There are not enough "keep previous data" feature - return the previous key's data until the new data has been loaded.

This feature is well explained in swr: https://swr.vercel.app/docs/advanced/understanding#return-previous-data-for-better-ux

There is an example on @nanostores /query: https://codesandbox.io/p/sandbox/nanostories-query-react-paging-rick-morty-q6ctwm

It shows how the content "jumps" when the user navigates to the next page (when the cache is empty).

@dkzlv
Copy link
Member

dkzlv commented Aug 15, 2024

@mrfratello Hey there!

Great suggestion. I think it may be of some use in the core, indeed. I'll think about adding it there in the upcoming release.

In the meantime I'll just say that it's fairly straightforward to implement in userland (even in the form of a reusable utility). Here's a simple implementation. I may have missed something there (e.g., data will be there even if error shows up which I'm not sure is the right call), but it seems quite stable to me.

@dkzlv dkzlv added the enhancement New feature or request label Aug 15, 2024
@mrfratello
Copy link
Contributor Author

Thanks for the example. Unfortunately, it looks like rocket science to me.

I have dragged this example into my project and it works as should.

But, I will wait for the implementation of this feature in the core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants