T
TanStack3y ago
like-gold

Migration to v5

I'm currently testing migration to V5 and was wondering why if I run the codemod its not picking up that I'm using the old syntax when setting query keys. I receive a number of unmodified files., with 0 errors, 0 skipped and 0 ok. Is there something I'm doing wrong?
9 Replies
absent-sapphire
absent-sapphire3y ago
What is the old syntax?
foreign-sapphire
foreign-sapphire3y ago
@HedgehogB FYI
like-gold
like-goldOP3y ago
@M00LTi sorry I should I have been more clear, version V5 has now kept one way of passing in query keys, one way was using an object and specfying querykey and queryfn, the other way was not using the object syntax. The code mod uses JScodeshift which checks the existing code to ensure react query code conforms to v5 standards. However, even if point the path to one ts file which is using the old syntax it doesn't fix it. I was wondering if I was doing something wrong.
ambitious-aqua
ambitious-aqua3y ago
Could you provide a code snippet, please? Did the codemod leave a message on the console about that the usage couldn’t be transformed?
like-gold
like-goldOP3y ago
import { useQuery } from "react-query";
import { Usertype } from "../types/types";
import axiosRequest from "../requests/requests";

const getUsers = async (signal?: AbortSignal) => {
const { data } = await axiosRequest.get<Usertype[]>(
"/allusers",
{
signal,
}
);
return data;
};

const UseQueryUsers = () =>
useQuery(["users"], ({ signal }) => getUsers(signal));

export default UseQueryUsers;
import { useQuery } from "react-query";
import { Usertype } from "../types/types";
import axiosRequest from "../requests/requests";

const getUsers = async (signal?: AbortSignal) => {
const { data } = await axiosRequest.get<Usertype[]>(
"/allusers",
{
signal,
}
);
return data;
};

const UseQueryUsers = () =>
useQuery(["users"], ({ signal }) => getUsers(signal));

export default UseQueryUsers;
No description
ambitious-aqua
ambitious-aqua3y ago
Thank you! It will be fixed one of the next releases. I will ping you once the fix is merged.
adverse-sapphire
adverse-sapphire3y ago
@HedgehogB does this codemod also update isLoading -> isPending? thanks!
ambitious-aqua
ambitious-aqua3y ago
Not yet. That will be done by a different codemod. Hopefully it will released next week.
like-gold
like-goldOP3y ago
@HedgehogB thank you

Did you find this page helpful?