fixing first thumbnail bug
This commit is contained in:
parent
91e83760d4
commit
90c2272720
1 changed files with 6 additions and 6 deletions
|
@ -8,20 +8,20 @@ export default function useThumbnail(claimThumbnail: ?string, containerRef: any)
|
|||
const [thumbnail, setThumbnail] = React.useState(FileRenderPlaceholder);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!claimThumbnail) return;
|
||||
if (!claimThumbnail) {
|
||||
return setThumbnail(FileRenderPlaceholder);
|
||||
}
|
||||
|
||||
const timer = setTimeout(() => {
|
||||
let newThumbnail = claimThumbnail;
|
||||
|
||||
if (
|
||||
containerRef.current &&
|
||||
containerRef.current.parentElement &&
|
||||
containerRef.current.parentElement.offsetWidth
|
||||
) {
|
||||
// generate the thumbnail url served by the cdn
|
||||
if (containerRef.current?.parentElement?.offsetWidth) {
|
||||
const w = containerRef.current.parentElement.offsetWidth;
|
||||
newThumbnail = getThumbnailCdnUrl({ thumbnail: newThumbnail, width: w, height: w });
|
||||
}
|
||||
|
||||
// update new thumbnail in state
|
||||
if (newThumbnail !== thumbnail) {
|
||||
setThumbnail(newThumbnail);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue