Patterns for when server side state dictates UI and app behaviour #2343
Unanswered
bitttttten
asked this question in
Q&A
Replies: 1 comment
-
I think your query component looks good. I'm not exactly sure about the optimistic ui update, it's best done with
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In my app, I have a few fields on the user object that come from the server that affect the UI of the app. This data can change a lot, so I was wondering what kind of practises or implementations people have done to accommodate this.
For my specific example, one field controls the status of the user's invite. Let's say it's called
inviteStatus
. I want to render some UI to manage an invite status if that value ispending
. If the status is not pending, then I don't need to render this part of the UI.For example:
This is no problem, I could do something like:
So now here are my questions and concerns about this approach. If I update the user, I have to implicitly update the query cache of react-query. Either by invalidating it, or manually triggering it. Some complexity comes if I want optimistic UI updates.
It seems quite involved, but not the end of the world. Is this an approach that's recommended? Or maybe I am missing a few things here and there.
Beta Was this translation helpful? Give feedback.
All reactions