Infinite loop when conditionally call child component calls the same query which is causing an error - TanStack