Replies: 2 comments
-
I'm not sure, I'd need to see an example. Generally, |
Beta Was this translation helpful? Give feedback.
0 replies
-
@raymondji Hi, did you figure out a solution to this? I am getting the same behaviour |
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
-
I'm using React Query to fetch a list of items and mutate the list of items when the user re-orders them (manually via drag and drop). E.g. re-ordering tickets in Trello/Jira. Specifically, when the user finishes dragging an item and drops it into its new spot in the list, I synchronously call
mutation.mutate()
whereconst mutation = useMutation(...)
;In order to immediately reflect the new ordering of items in the UI, I'm performing an optimistic update per the example code in the React Query docs. However, it seems like
onMutate
does not run synchronously*. My list component seems to flicker as the component first re-renders with the original item order, thenonMutate
gets run, and finally the component re-renders with the updated item order.*At least this seems to be the case; when I add
console.log("rendering")
in the component render method andconsole.log("onMutate")
inside theonMutate
method, I see this printed:Appreciate any guidance/suggestions on:
onMutate
does not run synchronously whenmutate()
is called)Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions