lbry-desktop/ui/component/viewers/imageViewer.jsx
togekk1 00017e241e Revert "Open the actual image when clicking on the image viewer"
This reverts commit 6a99947ac2d3fada59438d818599af6b68dcebd8.
2021-02-19 14:05:51 -05:00

32 lines
764 B
JavaScript

// @flow
import React from 'react';
import Card from 'component/common/card';
import ErrorText from 'component/common/error-text';
type Props = {
source: string,
};
function ImageViewer(props: Props) {
const { source } = props;
const [loadingError, setLoadingError] = React.useState(false);
return (
<React.Fragment>
{loadingError && (
<Card
title={__('Error displaying image')}
actions={<ErrorText>There was an error displaying the image. You may still download it.</ErrorText>}
/>
)}
{!loadingError && (
<div className="file-viewer">
<img src={source} onError={() => setLoadingError(true)} />
</div>
)}
</React.Fragment>
);
}
export default ImageViewer;