T
TanStack3y ago
wise-white

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
wise-white
wise-white3y 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);
wise-white
wise-whiteOP3y ago
wow it works, thanks @MrMentor

Did you find this page helpful?