Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit Post: Remove unnecessary effect in InitPatternModal #65734

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super small PR to simplify this.

);

if ( postType !== 'wp_block' || ! isNewPost ) {
return null;
Expand Down
Loading