Skip to content

Commit

Permalink
DataViews: Don't memoize every callback 'PagePages' component (#60103)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
  • Loading branch information
3 people committed Mar 25, 2024
1 parent 7800e6a commit 3229569
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 3229569

Please sign in to comment.