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 (onload) {
if (imgRef.current) { if (imgRef.current) {
const { naturalHeight, naturalWidth } = imgRef.current; const { naturalHeight, naturalWidth } = imgRef.current;
setIsPortraitImage(naturalHeight > naturalWidth); setIsPortraitImage(naturalHeight > naturalWidth);
} }
if (onload) {
onload(); onload();
} }
}} }}