Option to keep previous data in loadable when in loading state #3126
Answered
by
dai-shi
noodlefreeze
asked this question in
Ideas
-
Currently, loadable(atom) returns: { state: 'loading', data: undefined } when the underlying async atom is pending. In some UI patterns (infinite scrolling, polling refresh, optimistic updates), it is useful to keep the previous data during the loading phase, so the UI doesn't "flash empty". |
Beta Was this translation helpful? Give feedback.
Answered by
dai-shi
Aug 15, 2025
Replies: 1 comment 2 replies
-
First of all, this is not technically limited to There's no concept of "previous" data in the Jotai atom model. In your case, async atom -> loadable -> selectAtom should do. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
noodlefreeze
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First of all, this is not technically limited to
loadable
.There's no concept of "previous" data in the Jotai atom model.
However, sometimes "previous" data would be handy.
So, we provide a workaround util, which is
selectAtom
.In your case, async atom -> loadable -> selectAtom should do.