Skip to content

Commit

Permalink
destructure compsite.setCurrentId outside of effect to avoid a loop…
Browse files Browse the repository at this point in the history
…. Update dependency array
  • Loading branch information
chad1008 committed May 19, 2022
1 parent 53d6924 commit 5f94dcf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/components/src/alignment-matrix-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ export default function AlignmentMatrixControl( {
onChange( nextValue );
};

const { setCurrentId } = composite;

useEffect( () => {
if ( typeof value !== 'undefined' ) {
composite.setCurrentId( getItemId( baseId, value ) );
setCurrentId( getItemId( baseId, value ) );
}
}, [ value, composite.setCurrentId ] );
}, [ value, setCurrentId, baseId ] );

const classes = classnames(
'component-alignment-matrix-control',
Expand Down

0 comments on commit 5f94dcf

Please sign in to comment.