mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-11 20:52:00 -05:00
8f0a0439cd
Pull project id from `EditorContext` instead of `window` in file views GitOrigin-RevId: 78c2686d8bcd1e95414631ca77143fd9ae3edbc6
26 lines
673 B
JavaScript
26 lines
673 B
JavaScript
import React from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import { useEditorContext } from '../../../shared/context/editor-context'
|
|
|
|
export default function BinaryFileImage({ 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}
|
|
/>
|
|
)
|
|
}
|
|
|
|
BinaryFileImage.propTypes = {
|
|
fileName: PropTypes.string.isRequired,
|
|
fileId: PropTypes.string.isRequired,
|
|
onLoad: PropTypes.func.isRequired,
|
|
onError: PropTypes.func.isRequired,
|
|
}
|