Skip to content

Commit

Permalink
Annotations: Fix performance of BlockListBlock
Browse files Browse the repository at this point in the history
Because we passed an array of classes returned from `.filter` this
would always return a new array. Making `BlockListBlock` rerender.
  • Loading branch information
atimmer committed Dec 9, 2018
1 parent 3ceb332 commit 29694f1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/annotations/src/block/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import { uniq } from 'lodash';

/**
* WordPress dependencies
*/
Expand All @@ -15,9 +20,9 @@ const addAnnotationClassName = ( OriginalComponent ) => {
const annotations = select( 'core/annotations' ).__experimentalGetAnnotationsForBlock( clientId );

return {
className: annotations.map( ( annotation ) => {
className: uniq( annotations.map( ( annotation ) => {
return 'is-annotated-by-' + annotation.source;
} ),
} ) ).join( ' ' ),
};
} )( OriginalComponent );
};
Expand Down

0 comments on commit 29694f1

Please sign in to comment.