Skip to content

Commit

Permalink
Use useCallback to stop provider from constantly updating
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Sep 3, 2021
1 parent cf25c1f commit ae02bc2
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions packages/block-editor/src/components/list-view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,24 @@ function ListView(
isMounted.current = true;
}, [] );

const expand = ( clientId ) => {
if ( ! clientId ) {
return;
}
setExpandedState( { type: 'expand', clientId } );
};
const collapse = ( clientId ) => {
if ( ! clientId ) {
return;
}
setExpandedState( { type: 'collapse', clientId } );
};
const expand = useCallback(
( clientId ) => {
if ( ! clientId ) {
return;
}
setExpandedState( { type: 'expand', clientId } );
},
[ setExpandedState ]
);
const collapse = useCallback(
( clientId ) => {
if ( ! clientId ) {
return;
}
setExpandedState( { type: 'collapse', clientId } );
},
[ setExpandedState ]
);
const expandRow = ( row ) => {
expand( row?.dataset?.block );
};
Expand Down

0 comments on commit ae02bc2

Please sign in to comment.