From 832d1c53e9bca886851050f26907a9a2e6c55339 Mon Sep 17 00:00:00 2001 From: Andrew Serong <14988353+andrewserong@users.noreply.github.com> Date: Fri, 10 Dec 2021 17:03:37 +1100 Subject: [PATCH] Remove useMemo --- packages/block-library/src/image/image.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/packages/block-library/src/image/image.js b/packages/block-library/src/image/image.js index 4ae3a6352124d1..9fabb16c8277d8 100644 --- a/packages/block-library/src/image/image.js +++ b/packages/block-library/src/image/image.js @@ -30,7 +30,7 @@ import { __experimentalImageEditor as ImageEditor, __experimentalImageEditingProvider as ImageEditingProvider, } from '@wordpress/block-editor'; -import { useEffect, useMemo, useState, useRef } from '@wordpress/element'; +import { useEffect, useState, useRef } from '@wordpress/element'; import { __, sprintf, isRTL } from '@wordpress/i18n'; import { getFilename } from '@wordpress/url'; import { createBlock, switchToBlockType } from '@wordpress/blocks'; @@ -187,18 +187,10 @@ export default function Image( { // width and height. This resolves an issue in Safari where the loaded natural // witdth and height is otherwise lost when switching between alignments. // See: https://github.com/WordPress/gutenberg/pull/37210. - const { naturalWidth, naturalHeight } = useMemo( () => { - return { - naturalWidth: - imageRef.current?.naturalWidth || - loadedNaturalWidth || - undefined, - naturalHeight: - imageRef.current?.naturalHeight || - loadedNaturalHeight || - undefined, - }; - }, [ loadedNaturalWidth, loadedNaturalHeight, imageRef.current ] ); + const naturalWidth = + imageRef.current?.naturalWidth || loadedNaturalWidth || undefined; + const naturalHeight = + imageRef.current?.nautralHeight || loadedNaturalHeight || undefined; function onResizeStart() { toggleSelection( false );