Skip to content

Commit

Permalink
DataViews: Don't memoize every callback 'PagePages' component (WordPr…
Browse files Browse the repository at this point in the history
…ess#60103)

Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: oandregal <[email protected]>
  • Loading branch information
3 people authored and cbravobernal committed Apr 9, 2024
1 parent c1dd393 commit b3503d5
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions packages/edit-site/src/components/page-pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,27 +377,17 @@ export default function PagePages() {
);

const [ showAddPageModal, setShowAddPageModal ] = useState( false );
const openModal = useCallback( () => {
if ( ! showAddPageModal ) {
setShowAddPageModal( true );
}
}, [ showAddPageModal ] );
const closeModal = useCallback( () => {
if ( showAddPageModal ) {
setShowAddPageModal( false );
}
}, [ showAddPageModal ] );
const handleNewPage = useCallback(
( { type, id } ) => {
history.push( {
postId: id,
postType: type,
canvas: 'edit',
} );
closeModal();
},
[ history ]
);

const openModal = () => setShowAddPageModal( true );
const closeModal = () => setShowAddPageModal( false );
const handleNewPage = ( { type, id } ) => {
history.push( {
postId: id,
postType: type,
canvas: 'edit',
} );
closeModal();
};

// TODO: we need to handle properly `data={ data || EMPTY_ARRAY }` for when `isLoading`.
return (
Expand Down

0 comments on commit b3503d5

Please sign in to comment.