You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am experiencing a problem with optimistic updates using React Query's useMutation hook. The deletion and optimistic update logic work perfectly in the Replit environment((Cloud Environment)) but not on localhost.
Issue
The useDeleteAccount hook works as expected in terms of deleting the data on the backend in both environments. However, the optimistic update is only reflected in the Replit environment and not on localhost
`import API from "@/app/axios";
import { toast } from "sonner";
import { useMutation, useQueryClient } from "@tanstack/react-query";
export default useDeleteAccount;
`
Also i am experiencing problem only with this deletion hook adding account and updating accounts works flawlessly in both environment.Thank you so much for your help.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am experiencing a problem with optimistic updates using React Query's useMutation hook. The deletion and optimistic update logic work perfectly in the Replit environment((Cloud Environment)) but not on localhost.
Issue
The useDeleteAccount hook works as expected in terms of deleting the data on the backend in both environments. However, the optimistic update is only reflected in the Replit environment and not on localhost
`import API from "@/app/axios";
import { toast } from "sonner";
import { useMutation, useQueryClient } from "@tanstack/react-query";
const deleteUser = async (data: { data: string[] }) => {
const response = await API.post("/account/delete", data);
return response.data;
};
import useAddNewAccountModal from "@/hooks/accounts/account-sheet-modal";
const useDeleteAccount = () => {
const { onClose } = useAddNewAccountModal();
const queryClient = useQueryClient();
return useMutation({
mutationFn: deleteUser,
onMutate: async (deletedData) => {
await queryClient.cancelQueries({ queryKey: ['accounts'] });
const previousAccounts = queryClient.getQueryData(['accounts']);
});
};
export default useDeleteAccount;
`
Also i am experiencing problem only with this deletion hook adding account and updating accounts works flawlessly in both environment.Thank you so much for your help.
Beta Was this translation helpful? Give feedback.
All reactions