I'm trying out react-query on a NextJS project but somehow I can't control when it runs (partially). No request goes out but it still shows up as an entry on the react-query dev tools:
const { data, status } = useQuery({
queryKey: ['user', userId],
queryFn: getUserInfo,
enabled: !!userId
});
What I'm doing here is enabling this query only when the userId
has a value. It does work in a sense because no request comes out but when looking at the dev tools for react-query, I see a query key with ['user', null]
and then another entry with a query key of ['user', '1234']
.
Edit
It is marked as inactive so I may just be worried about nothing but I don't think it should show up as an entry in the list of queries inside of the dev tool. Is it possible to not have it show up if it doesn't run?