Skip to content

Commit

Permalink
Edit Post: Remove unnecessary effect in InitPatternModal (#65734)
Browse files Browse the repository at this point in the history
Co-authored-by: tyxla <[email protected]>
Co-authored-by: mirka <[email protected]>
  • Loading branch information
3 people authored Sep 30, 2024
1 parent 20dc9b7 commit ad88b22
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions packages/edit-post/src/components/init-pattern-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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( '' );

Expand All @@ -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;
Expand Down

0 comments on commit ad88b22

Please sign in to comment.