mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
b7802674d5
React `project-context` GitOrigin-RevId: 6a23437d6e6a328ff5854622ff903d348db1f8b8
25 lines
645 B
JavaScript
25 lines
645 B
JavaScript
import PropTypes from 'prop-types'
|
|
import { useProjectContext } from '../../../shared/context/project-context'
|
|
|
|
export default function FileViewImage({ fileName, fileId, onLoad, onError }) {
|
|
const { _id: projectId } = useProjectContext({
|
|
_id: 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,
|
|
}
|