How to call useQuery hook conditionally?

Because of the Rules of Hooks, one shouldn’t call hooks conditionally. So how does one fetch data conditionally using useQuery? For example, let’s say I want to fetch data inside a functional component, but only if someState === someValue? i.e I want to avoid calling useQuery() before any conditions because fetching data at these time doesn’t make sense.