Skip to content

Commit

Permalink
Global Styles: Fix React Compiler variable mutation error (#66410)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: tyxla <[email protected]>
  • Loading branch information
3 people authored Oct 24, 2024
1 parent 62e0e6f commit ae9db95
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,18 +301,17 @@ function ShadowEditor( { shadow, onChange } ) {
const shadowParts = useMemo( () => getShadowParts( shadow ), [ shadow ] );

const onChangeShadowPart = ( index, part ) => {
shadowParts[ index ] = part;
onChange( shadowParts.join( ', ' ) );
const newShadowParts = [ ...shadowParts ];
newShadowParts[ index ] = part;
onChange( newShadowParts.join( ', ' ) );
};

const onAddShadowPart = () => {
shadowParts.push( defaultShadow );
onChange( shadowParts.join( ', ' ) );
onChange( [ ...shadowParts, defaultShadow ].join( ', ' ) );
};

const onRemoveShadowPart = ( index ) => {
shadowParts.splice( index, 1 );
onChange( shadowParts.join( ', ' ) );
onChange( shadowParts.filter( ( p, i ) => i !== index ).join( ', ' ) );
};

return (
Expand Down

0 comments on commit ae9db95

Please sign in to comment.