From 7688c163856b8992bc8114defab53eee808edcc4 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Tue, 20 Jun 2023 11:31:27 +0400 Subject: [PATCH] Block Editor: Remove redundant callback memoization from 'ImageURLInputUI' (#51658) --- .../url-popover/image-url-input-ui.js | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/block-editor/src/components/url-popover/image-url-input-ui.js b/packages/block-editor/src/components/url-popover/image-url-input-ui.js index 57084ae76cb25..2f849eaad7884 100644 --- a/packages/block-editor/src/components/url-popover/image-url-input-ui.js +++ b/packages/block-editor/src/components/url-popover/image-url-input-ui.js @@ -2,7 +2,7 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { useRef, useState, useCallback } from '@wordpress/element'; +import { useRef, useState } from '@wordpress/element'; import { ToolbarButton, Button, @@ -50,16 +50,16 @@ const ImageURLInputUI = ( { // Use internal state instead of a ref to make sure that the component // re-renders when the popover's anchor updates. const [ popoverAnchor, setPopoverAnchor ] = useState( null ); - const openLinkUI = useCallback( () => { + const openLinkUI = () => { setIsOpen( true ); - } ); + }; const [ isEditingLink, setIsEditingLink ] = useState( false ); const [ urlInput, setUrlInput ] = useState( null ); const autocompleteRef = useRef( null ); - const startEditLink = useCallback( () => { + const startEditLink = () => { if ( linkDestination === LINK_DESTINATION_MEDIA || linkDestination === LINK_DESTINATION_ATTACHMENT @@ -67,17 +67,17 @@ const ImageURLInputUI = ( { setUrlInput( '' ); } setIsEditingLink( true ); - } ); + }; - const stopEditLink = useCallback( () => { + const stopEditLink = () => { setIsEditingLink( false ); - } ); + }; - const closeLinkUI = useCallback( () => { + const closeLinkUI = () => { setUrlInput( null ); stopEditLink(); setIsOpen( false ); - } ); + }; const getUpdatedLinkTargetSettings = ( value ) => { const newLinkTarget = value ? '_blank' : undefined; @@ -106,7 +106,7 @@ const ImageURLInputUI = ( { }; }; - const onFocusOutside = useCallback( () => { + const onFocusOutside = () => { return ( event ) => { // The autocomplete suggestions list renders in a separate popover (in a portal), // so onFocusOutside fails to detect that a click on a suggestion occurred in the @@ -123,9 +123,9 @@ const ImageURLInputUI = ( { setUrlInput( null ); stopEditLink(); }; - } ); + }; - const onSubmitLinkChange = useCallback( () => { + const onSubmitLinkChange = () => { return ( event ) => { if ( urlInput ) { // It is possible the entered URL actually matches a named link destination. @@ -144,14 +144,14 @@ const ImageURLInputUI = ( { setUrlInput( null ); event.preventDefault(); }; - } ); + }; - const onLinkRemove = useCallback( () => { + const onLinkRemove = () => { onChangeUrl( { linkDestination: LINK_DESTINATION_NONE, href: '', } ); - } ); + }; const getLinkDestinations = () => { const linkDestinations = [