T
TanStack2y ago
stormy-gold

how can i re-run useQuery if queryKey changed with help of props without watch and refetch?

step 1 - change 1 to 2 in input https://codesandbox.io/p/sandbox/strange-estrela-wx59mw actual - it is not fetch again after change number in input expected - it should fetch again whenever queryKey or change input
2 Replies
extended-salmon
extended-salmon2y ago
So in your example you are passing a plain value by doing props.postId instead of a reactive value. Easiet way to fix that would be to convert it ref and pass it to queryKey in that form
const { postId } = toRefs(props);
const { postId } = toRefs(props);
stormy-gold
stormy-goldOP2y ago
wow it works, thanks @MrMentor

Did you find this page helpful?