From ad88b2271207264c1503f692222ba814daebfcf4 Mon Sep 17 00:00:00 2001 From: Marin Atanasov <8436925+tyxla@users.noreply.github.com> Date: Mon, 30 Sep 2024 13:55:41 +0300 Subject: [PATCH] Edit Post: Remove unnecessary effect in InitPatternModal (#65734) Co-authored-by: tyxla Co-authored-by: mirka <0mirka00@git.wordpress.org> --- .../src/components/init-pattern-modal/index.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/packages/edit-post/src/components/init-pattern-modal/index.js b/packages/edit-post/src/components/init-pattern-modal/index.js index 5b94e838dbcad..6c7cd269a27de 100644 --- a/packages/edit-post/src/components/init-pattern-modal/index.js +++ b/packages/edit-post/src/components/init-pattern-modal/index.js @@ -11,12 +11,11 @@ import { ToggleControl, TextControl, } from '@wordpress/components'; -import { useEffect, useState } from '@wordpress/element'; +import { useState } from '@wordpress/element'; import { store as editorStore } from '@wordpress/editor'; export default function InitPatternModal() { const { editPost } = useDispatch( editorStore ); - const [ isModalOpen, setIsModalOpen ] = useState( false ); const [ syncType, setSyncType ] = useState( undefined ); const [ title, setTitle ] = useState( '' ); @@ -28,14 +27,9 @@ export default function InitPatternModal() { isNewPost: isCleanNewPost(), }; }, [] ); - - useEffect( () => { - if ( isNewPost && postType === 'wp_block' ) { - setIsModalOpen( true ); - } - // We only want the modal to open when the page is first loaded. - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [] ); + const [ isModalOpen, setIsModalOpen ] = useState( () => + isNewPost && postType === 'wp_block' ? true : false + ); if ( postType !== 'wp_block' || ! isNewPost ) { return null;