Skip to content

Commit

Permalink
fix: export component
Browse files Browse the repository at this point in the history
  • Loading branch information
nhussein11 committed Jul 31, 2023
1 parent 90b5068 commit f8f1eae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions src/lib/components/image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,31 @@ export const ImageIPFS = ({
fallbackImage = DEFAULT_FALLBACK_IMAGE,
...props
}: IpfsImageProps): JSX.Element => {
const imgLoading = lazy === true ? 'lazy' : 'eager'
const [imgSrc, setImgSrc] = useState<string>('')
const lazyLoading = lazy === true ? 'lazy' : 'eager'
const [imageURL, setImageURL] = useState<string>('')

useEffect(() => {
const imgSrcCleaned = getIpfsURL(gateway, hash)
setImgSrc(imgSrcCleaned)
const cleanedImageURL = getIpfsURL(gateway, hash)
setImageURL(cleanedImageURL)
}, [hash, gateway])

const handleOnError = (event: SyntheticEvent<HTMLImageElement, Event>): void => {
const handleImageError = (event: SyntheticEvent<HTMLImageElement, Event>): void => {
if (event.type === 'error') {
setImgSrc(fallbackImage)
setImageURL(fallbackImage)
}
}

return (
<img
src={imgSrc}
src={imageURL}
alt={alt}
width={width}
height={height}
style={style}
className={className}
loading={imgLoading}
loading={lazyLoading}
onError={(event) => {
handleOnError(event)
handleImageError(event)
}}
{...props}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './dummy'
export * from './image'

0 comments on commit f8f1eae

Please sign in to comment.