Skip to content

Commit

Permalink
try removing memo usages
Browse files Browse the repository at this point in the history
  • Loading branch information
gwwar committed Sep 20, 2021
1 parent 7efb06f commit 2752f76
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 21 deletions.
17 changes: 2 additions & 15 deletions packages/block-editor/src/components/list-view/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { moreVertical } from '@wordpress/icons';
import { useState, useRef, useEffect, memo } from '@wordpress/element';
import { useState, useRef, useEffect } from '@wordpress/element';
import { useDispatch, useSelect } from '@wordpress/data';

/**
Expand All @@ -41,7 +41,7 @@ const ROW_VARIANTS = {
};
const DRAG_CONSTANTS = { left: -10, right: 10 };

function ListViewBlock( {
export default function ListViewBlock( {
block,
isSelected,
isBranchSelected,
Expand Down Expand Up @@ -334,16 +334,3 @@ function ListViewBlock( {
</TreeGridRow>
);
}

function shouldSkipUpdateIfDragging( prevProps, nextProps ) {
if ( prevProps.draggingId && nextProps.draggingId ) {
const samePosition = nextProps.listPosition === prevProps.listPosition;
const sameParent = nextProps.parentId === prevProps.parentId;
const expanded = nextProps.isExpanded === prevProps.isExpanded;
return samePosition && sameParent && expanded;
}
// If not dragging, default to native behavior of always rendering if the parent has rendered.
return false;
}

export default memo( ListViewBlock, shouldSkipUpdateIfDragging );
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
store as blockEditorStore,
} from '@wordpress/block-editor';
import { Button } from '@wordpress/components';
import { memo } from '@wordpress/element';
import {
useFocusOnMount,
useFocusReturn,
Expand All @@ -23,7 +22,7 @@ import { ESCAPE } from '@wordpress/keycodes';
*/
import { store as editPostStore } from '../../store';

function ListViewSidebar() {
export default function ListViewSidebar() {
const { setIsListViewOpened } = useDispatch( editPostStore );

const { clearSelectedBlock, selectBlock } = useDispatch( blockEditorStore );
Expand Down Expand Up @@ -72,4 +71,3 @@ function ListViewSidebar() {
</div>
);
}
export default memo( ListViewSidebar );
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
useInstanceId,
useMergeRefs,
} from '@wordpress/compose';
import { memo } from '@wordpress/element';
import { useDispatch } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { closeSmall } from '@wordpress/icons';
Expand All @@ -23,7 +22,7 @@ import { ESCAPE } from '@wordpress/keycodes';
*/
import { store as editSiteStore } from '../../store';

function ListViewSidebar() {
export default function ListViewSidebar() {
const { setIsListViewOpened } = useDispatch( editSiteStore );

const { clearSelectedBlock, selectBlock } = useDispatch( blockEditorStore );
Expand Down Expand Up @@ -71,4 +70,3 @@ function ListViewSidebar() {
</div>
);
}
export default memo( ListViewSidebar );

0 comments on commit 2752f76

Please sign in to comment.