Skip to content
Closed
Prev Previous commit
Next Next commit
Memoize clientIds to avoid draggable re-render
  • Loading branch information
talldan committed Sep 30, 2020
commit f5ad074d1177af05172f5587afb0f0c59774a6a2
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import classnames from 'classnames';
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
import { forwardRef } from '@wordpress/element';
import { forwardRef, useMemo } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -85,10 +85,12 @@ const BlockNavigationBlockContents = forwardRef(
}
);

const clientIds = useMemo( () => [ clientId ], [ clientId ] );

return (
<BlockDraggable
clientIds={ [ block.clientId ] }
elementId={ `block-navigation-block-${ block.clientId }` }
clientIds={ clientIds }
elementId={ `block-navigation-block-${ clientId }` }
>
{ ( { isDraggable, onDraggableStart, onDraggableEnd } ) => (
<BlockNavigationBlockSelectButton
Expand Down