(
{ fallbackSrc, src, alt, fetchPriority = 'auto', ...props }: ImageProps,
ref?: Ref<HTMLImageElement>,
)
| 40 | }; |
| 41 | |
| 42 | const ImageComponent = ( |
| 43 | { fallbackSrc, src, alt, fetchPriority = 'auto', ...props }: ImageProps, |
| 44 | ref?: Ref<HTMLImageElement>, |
| 45 | ): ReactElement => { |
| 46 | const finalFallbackSrc = |
| 47 | fallbackSrc ?? fallbackSrcByType[props.type ?? ImageType.Post]; |
| 48 | |
| 49 | const onError = (event: SyntheticEvent<HTMLImageElement>): void => { |
| 50 | if (finalFallbackSrc && finalFallbackSrc !== event.currentTarget.src) { |
| 51 | // eslint-disable-next-line no-param-reassign |
| 52 | event.currentTarget.src = finalFallbackSrc; |
| 53 | if (event.currentTarget.srcset) { |
| 54 | // eslint-disable-next-line no-param-reassign |
| 55 | event.currentTarget.srcset = finalFallbackSrc; |
| 56 | } |
| 57 | } |
| 58 | }; |
| 59 | |
| 60 | return ( |
| 61 | <img |
| 62 | {...props} |
| 63 | /* @ts-expect-error - Not supported by react yet */ /* eslint-disable react/no-unknown-property */ |
| 64 | fetchpriority={fetchPriority} |
| 65 | ref={ref} |
| 66 | alt={alt} |
| 67 | src={src ?? finalFallbackSrc} |
| 68 | onError={onError} |
| 69 | /> |
| 70 | ); |
| 71 | }; |
| 72 | |
| 73 | export const Image = forwardRef(ImageComponent); |
nothing calls this directly
no outgoing calls
no test coverage detected