move calc into onLoad

This commit is contained in:
Josh Hawkins 2024-05-02 12:18:20 -05:00
parent efde23ed81
commit d55d862d3e

View File

@ -45,11 +45,12 @@ export default function CameraImage({
onLoad={() => { onLoad={() => {
setHasLoaded(true); setHasLoaded(true);
if (imgRef.current) {
const { naturalHeight, naturalWidth } = imgRef.current;
setIsPortraitImage(naturalHeight > naturalWidth);
}
if (onload) { if (onload) {
if (imgRef.current) {
const { naturalHeight, naturalWidth } = imgRef.current;
setIsPortraitImage(naturalHeight > naturalWidth);
}
onload(); onload();
} }
}} }}