import { useState } from 'react'; /** * A src that swaps to a fallback when the image fails to load. TMDB image * paths are editable on TMDB's side, so a poster that existed when a chain * was played can 404 later; without this an old game's review, or the Home * example loop, shows broken-image icons instead of placeholder art. */ export function useImageFallback(src: string | null, fallback: string) { const [failedSrc, setFailedSrc] = useState(null); const resolved = src && failedSrc !== src ? src : fallback; return { src: resolved, onError: () => { if (src) setFailedSrc(src); }, }; }