vue-query hooks can only be used inside setup() function #5178
Unanswered
khaledOghli
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Use const isEnabled = computed(() => Boolean(currentTaskID.value))
const query = useQuery({
queryKey,
queryFn,
// query will start loading when `currentTaskID` is set
enabled: isEnabled
}) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Guys 👍🏻
How Can I use " useQuery " to get data inside method in setup.!?
`
import useQuery from "~/composables/useFetchQuery";
const getEmittedData = (taskID, toggleInfo) => {
if (toggleInfo) {
const currentHistoryRow = data.value.newHistories.filter((item) => item.taskID === taskID);
currentTaskID.value = taskID;
const { isLoading } = useQuery.fetchQuery(
[
historyFeedback-${taskID}
],getHistoryFeedback,
onHistoryFeedbackSuccess,
onHistoryFeedbackError
);
currentHistoryRow['isLoading'] = isLoading;
}
};
`
Uncaught Error: vue-query hooks can only be used inside setup() function.
Beta Was this translation helpful? Give feedback.
All reactions