Skip loading alt styles until speciesId is present

Before this change, when loading an outfit by ID, we'd send a request
to `/species/null/alt-styles.json`, which would come back as a 404,
oops lol
This commit is contained in:
Emi Matchu 2024-02-08 10:46:37 -08:00
parent 118ec6aa1a
commit 46dc4cf009

View file

@ -1,10 +1,11 @@
import { useQuery } from "@tanstack/react-query";
export function useAltStylesForSpecies(speciesId, options = {}) {
export function useAltStylesForSpecies(speciesId, options = {enabled = true}) {
return useQuery({
...options,
queryKey: ["altStylesForSpecies", String(speciesId)],
queryFn: () => loadAltStylesForSpecies(speciesId),
enabled: options.enabled && speciesId != null,
});
}