diff --git a/packages/block-library/src/latest-posts/edit.js b/packages/block-library/src/latest-posts/edit.js index ab792ae0e353d..7914f10be6bde 100644 --- a/packages/block-library/src/latest-posts/edit.js +++ b/packages/block-library/src/latest-posts/edit.js @@ -155,15 +155,11 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) { ); // If a user clicks to a link prevent redirection and show a warning. - const { createWarningNotice, removeNotice } = useDispatch( noticeStore ); - let noticeId; + const { createWarningNotice } = useDispatch( noticeStore ); const showRedirectionPreventedNotice = ( event ) => { event.preventDefault(); - // Remove previous warning if any, to show one at a time per block. - removeNotice( noticeId ); - noticeId = `block-library/core/latest-posts/redirection-prevented/${ instanceId }`; createWarningNotice( __( 'Links are disabled in the editor.' ), { - id: noticeId, + id: `block-library/core/latest-posts/redirection-prevented/${ instanceId }`, type: 'snackbar', } ); }; diff --git a/packages/block-library/src/table-of-contents/edit.js b/packages/block-library/src/table-of-contents/edit.js index 33d6e6896fb20..c95b89200cb88 100644 --- a/packages/block-library/src/table-of-contents/edit.js +++ b/packages/block-library/src/table-of-contents/edit.js @@ -17,7 +17,7 @@ import { ToolbarGroup, } from '@wordpress/components'; import { useDispatch, useSelect } from '@wordpress/data'; -import { renderToString, useRef } from '@wordpress/element'; +import { renderToString } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { useInstanceId } from '@wordpress/compose'; import { store as noticeStore } from '@wordpress/notices'; @@ -58,15 +58,11 @@ export default function TableOfContentsEdit( { ); // If a user clicks to a link prevent redirection and show a warning. - const { createWarningNotice, removeNotice } = useDispatch( noticeStore ); - const noticeIdRef = useRef(); + const { createWarningNotice } = useDispatch( noticeStore ); const showRedirectionPreventedNotice = ( event ) => { event.preventDefault(); - // Remove previous warning if any, to show one at a time per block. - removeNotice( noticeIdRef.current ); - noticeIdRef.current = `block-library/core/table-of-contents/redirection-prevented/${ instanceId }`; createWarningNotice( __( 'Links are disabled in the editor.' ), { - id: noticeIdRef.current, + id: `block-library/core/table-of-contents/redirection-prevented/${ instanceId }`, type: 'snackbar', } ); };