I am working on a table where I need to return images in the first column. The below code works fine except if it doesn't find the image then I get an error.
I would like to check if the file exists and if it does not exist, to return a default image. How should I approach this?
Thanks,
Cell: cellProps => {
const imgPath = cellProps.row.ExternalID;
return (
<img
src={require(`../images/${imgPath}.png`)}
alt=""
/>
);
}