i'm beginner of react-query.
i made a simple CRUD app. (MemoList)
when update content, react-query invalidateQueies not working...
this is my code.
export function updateOne(updateContent, id) {
return api.patch(`/api/content/${id}`, updateContent);
}
export function findOne(id) {
return api.get(`/${id}`);
}
UpdateList.js
const mutations = useMutation(updateOne, {
onMutate: (value) => {
console.log("value", value);
},
});
when submitButton triggers,
mutations.mutate(updateContentObj, id);
navigate(`/detail/${id}`);
detail.js
const { isLoading, isError, data, error } = useQuery(
["detail"],
() => {
return findOne(id);
},
{
select: (data) => {
return data.data;
},
onSuccess: () => {
queryClient.invalidateQueries(["detail"]);
},
onError: () => {
console.error(`Error: ${error.message}`);
},
}
);
result of onMutate console -> console show updateValue correctly.
however, in detail page, it was not updated. just same before update.
how can i fix it?