fix(FN-373): stop stack reset on every render in CategoryGrid
useTranslation returns a fresh `t` each render, so including it in the useEffect deps caused the effect to re-fire continuously, resetting the drill-down stack immediately after handleSelect pushed a child level. Result: clicking a parent category in grid view did nothing — no API call, no UI change, no navigation. Reproduced via Playwright on dev.sase.tr. Drop `t` from the dep array (key is static; locale changes mid-session are rare and acceptable to render stale until the next prop change).
This commit is contained in:
@@ -53,10 +53,15 @@ export function CategoryGrid({
|
||||
const [imageOverrides, setImageOverrides] = useState<Map<string, string>>(new Map());
|
||||
const prefetchedRef = useRef<Set<string>>(new Set());
|
||||
|
||||
// Reset stack when input categories prop changes (parent navigation)
|
||||
// Reset stack when input categories prop changes (parent navigation).
|
||||
// `t` is intentionally excluded: useTranslation returns a fresh function each
|
||||
// render, so including it would re-fire the effect on every render and reset
|
||||
// the stack immediately after handleSelect pushes a child level — making
|
||||
// parent-category clicks appear to do nothing.
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: t identity is unstable; key is static
|
||||
useEffect(() => {
|
||||
setStack([{ id: parentId ?? null, name: t("categories.root"), categories }]);
|
||||
}, [categories, parentId, t]);
|
||||
}, [categories, parentId]);
|
||||
|
||||
const current = stack[stack.length - 1];
|
||||
const currentCategories = current.categories;
|
||||
|
||||
Reference in New Issue
Block a user