diff --git a/packages/grafana-ui/src/components/Table/TableNG/Cells/ImageCell.tsx b/packages/grafana-ui/src/components/Table/TableNG/Cells/ImageCell.tsx index 805374f4471..e79fc968d54 100644 --- a/packages/grafana-ui/src/components/Table/TableNG/Cells/ImageCell.tsx +++ b/packages/grafana-ui/src/components/Table/TableNG/Cells/ImageCell.tsx @@ -1,17 +1,23 @@ import { css } from '@emotion/css'; +import { useState } from 'react'; import { TableCellDisplayMode } from '../../types'; import { MaybeWrapWithLink } from '../components/MaybeWrapWithLink'; import { ImageCellProps, TableCellStyles } from '../types'; export const ImageCell = ({ cellOptions, field, value, rowIdx }: ImageCellProps) => { + const [error, setError] = useState(false); const { text } = field.display!(value); const { alt, title } = cellOptions.type === TableCellDisplayMode.Image ? cellOptions : { alt: undefined, title: undefined }; + if (!text) { + return null; + } + return ( - {alt} + {error ? text : {alt} setError(true)} />} ); };