overleaf/services/web/frontend/js/features/file-view/components/file-view-image.js
Alf Eaton 7c97f8ab6e Switch to new JSX runtime (#4225)
* Use new JSX runtime and update Babel Node target
* Update .eslintrc
* Remove React imports

GitOrigin-RevId: 559de0267f8f2934c56a860ea8701bb522aa861a
2021-06-24 02:06:59 +00:00

25 lines
643 B
JavaScript

import PropTypes from 'prop-types'
import { useEditorContext } from '../../../shared/context/editor-context'
export default function FileViewImage({ fileName, fileId, onLoad, onError }) {
const { projectId } = useEditorContext({
projectId: PropTypes.string.isRequired,
})
return (
<img
src={`/project/${projectId}/file/${fileId}`}
onLoad={onLoad}
onError={onError}
onAbort={onError}
alt={fileName}
/>
)
}
FileViewImage.propTypes = {
fileName: PropTypes.string.isRequired,
fileId: PropTypes.string.isRequired,
onLoad: PropTypes.func.isRequired,
onError: PropTypes.func.isRequired,
}