import React,{useEffect,useState} from 'react'; import {pickReferences,rankLabel,referenceUrl} from './references.mjs'; // One small file per product, fetched once and kept for the session. const libraries=new Map(); const load=category=>{ if(!libraries.has(category))libraries.set(category,fetch(referenceUrl(category)).then(r=>r.ok?r.json():null).catch(()=>null)); return libraries.get(category); }; export default function ReferencePhotos({record}){ const [library,setLibrary]=useState(null); const wanted=Boolean(record?.references?.length); useEffect(()=>{ let current=true; setLibrary(null); if(wanted)load(record.category).then(value=>{if(current)setLibrary(value)}); return()=>{current=false}; },[record?.id,record?.category,wanted]); const items=pickReferences(record,library); if(!items.length)return null; return

Closest normal reference photos

Normal training photos of this product that look most like the photo above. They are for comparison only and do not change the result.

{items.map((item,index)=>
{`Normal
{rankLabel(index)}
)}
{library?.attribution&&

{library.attribution}

}
; }