Skip to content

Commit

Permalink
Wrap insertControllersMenu with a useCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
medied committed Jun 6, 2024
1 parent b52c358 commit b07803c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/link/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
useState,
useEffect,
useLayoutEffect,
useCallback,
} from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import wikipediaPreview from 'wikipedia-preview';
Expand All @@ -27,7 +28,7 @@ export const PreviewEditUI = ( {
setSelectingSection( true );
};

const insertControllersMenu = () => {
const insertControllersMenu = useCallback( () => {
const preview = document.querySelector( '.wikipediapreview' );
const previewHeader = document.querySelector(
'.wikipediapreview-header'
Expand Down Expand Up @@ -56,7 +57,7 @@ export const PreviewEditUI = ( {
.querySelector( '.wikipediapreview-edit-preview-container' )
.setAttribute( 'dir', preview.getAttribute( 'dir' ) );
}
};
}, [] );

useEffect( () => {
const { title, lang } = activeAttributes;
Expand All @@ -81,7 +82,7 @@ export const PreviewEditUI = ( {
?.removeEventListener( 'click', toggleControllersMenu );
};
}
}, [ previewHtml, selectingSection ] );
}, [ previewHtml, selectingSection, insertControllersMenu ] );

useLayoutEffect( () => {
document
Expand Down

0 comments on commit b07803c

Please sign in to comment.