-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Add support for offline/local first applications #10545
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
base: next
Are you sure you want to change the base?
Conversation
EditPostPage.setInputValue( | ||
'input', | ||
'title', | ||
'Lorem Ipsum again{enter}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because react-query now persist queries and mutations for offline mode, the previous test now leaks into the second (e.g. this post has its title changed to Lorem Ipsum). I tried to configure testIsolation in Cypress but our version is probably too old
d440e8e
to
9d66e05
Compare
isPending, | ||
isPlaceholderData, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those linter warnings make no sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed: it just needed a rebase 😊
I can't see a way to test this except e2e. Not sure if we can simulate network loss with cypress though |
@djhi since the simple demo has the react-query DevTools enabled, you can use them to simulate network loss I believe (clicking on the 'Wifi' icon does the job). A bit ugly but it should work! |
Problem
React-admin currently don't handle well the loss of network connectivity: in any demo, if you go to a list page, then simulate being offline using the devtool and try to go to the second page of the same list, it will still display the first page data while the pagination will indeed indicate you are on page 2.
We handled it a bit better by at least showing users a notification when they try to load new data while offline but we can do better and allow for resumable mutations.
Solution
ListContext
include theisPaused
andisPlaceholderData
props from react-query and update components/hooks accordinglyempty
component when those two props are true (ideally we should have a dedicated component for that or handle the case in the default empty but this is achievable in userland)mutationKey
to all mutations so that we can provide default functions for them at thequeryClient
level (required by react-query: https://tanstack.com/query/latest/docs/framework/react/guides/mutations#persisting-offline-mutations)How To Test
Then:
?mutationMode=optimistic
link first.?mutationMode=undoable
link first.f00bar
as the post title to trigger an error once the network is online.Additional Checks
master
for a bugfix, ornext
for a featureAlso, please make sure to read the contributing guidelines.