From 46dc4cf0092ca443aedb18f9f1c00d9e436a50cf Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Thu, 8 Feb 2024 10:46:37 -0800 Subject: [PATCH] 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 --- app/javascript/wardrobe-2020/loaders/alt-styles.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/javascript/wardrobe-2020/loaders/alt-styles.js b/app/javascript/wardrobe-2020/loaders/alt-styles.js index 86dbca08..49a1ae1f 100644 --- a/app/javascript/wardrobe-2020/loaders/alt-styles.js +++ b/app/javascript/wardrobe-2020/loaders/alt-styles.js @@ -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, }); }