From 4c58c5d448adda37b25294c48c4e6e3cd8a08583 Mon Sep 17 00:00:00 2001 From: Igor <35524806+igorschoester@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:45:18 +0100 Subject: [PATCH] Remove cache around changing link The cache via useCallback is too greedy. Everything is re-created already (no useCallback around all other functions). Therefore, opting to remove the cache (useCallback) here for an easy fix. --- packages/js/src/inline-links/inline.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/js/src/inline-links/inline.js b/packages/js/src/inline-links/inline.js index 3da86476ef1..46888772a3f 100644 --- a/packages/js/src/inline-links/inline.js +++ b/packages/js/src/inline-links/inline.js @@ -7,7 +7,7 @@ import PropTypes from "prop-types"; /** * WordPress dependencies */ -import { useMemo, useState, useCallback } from "@wordpress/element"; +import { useMemo, useState } from "@wordpress/element"; import { __, sprintf } from "@wordpress/i18n"; import { withSpokenMessages, Popover } from "@wordpress/components"; import { prependHTTP } from "@wordpress/url"; @@ -190,7 +190,12 @@ function InlineLinkUI( { } }; - const onChangeLink = useCallback( ( nextValue ) =>{ + /** + * Handles the change of the link. + * @param {Object} nextValue The next link URL. + * @returns {void} + */ + const onChangeLink = ( nextValue ) => { /* * Merge with values from state, both for the purpose of assigning the next state value, and for use in constructing the new link format if * the link is ready to be applied. @@ -256,7 +261,7 @@ function InlineLinkUI( { } actionCompleteMessage( newUrl ); - }, [] ); + }; const NoFollowHelpLink =