diff --git a/src/components/map/MapToken.js b/src/components/map/MapToken.js index f457c7c..995edf0 100644 --- a/src/components/map/MapToken.js +++ b/src/components/map/MapToken.js @@ -183,15 +183,14 @@ function MapToken({ const imageRef = useRef(); useEffect(() => { const image = imageRef.current; + if (!image) { + return; + } + const canvas = image.getCanvas(); const pixelRatio = canvas.pixelRatio || 1; - if ( - image && - tokenSourceStatus === "loaded" && - tokenWidth > 0 && - tokenHeight > 0 - ) { + if (tokenSourceStatus === "loaded" && tokenWidth > 0 && tokenHeight > 0) { const maxImageSize = token ? Math.max(token.width, token.height) : 512; // Default to 512px const maxTokenSize = Math.max(tokenWidth, tokenHeight); // Constrain image buffer to original image size