Skip to content

Commit ae9db95

Browse files
Mamadukatyxla
andauthored
Global Styles: Fix React Compiler variable mutation error (#66410)
Co-authored-by: Mamaduka <[email protected]> Co-authored-by: tyxla <[email protected]>
1 parent 62e0e6f commit ae9db95

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

packages/edit-site/src/components/global-styles/shadows-edit-panel.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -301,18 +301,17 @@ function ShadowEditor( { shadow, onChange } ) {
301301
const shadowParts = useMemo( () => getShadowParts( shadow ), [ shadow ] );
302302

303303
const onChangeShadowPart = ( index, part ) => {
304-
shadowParts[ index ] = part;
305-
onChange( shadowParts.join( ', ' ) );
304+
const newShadowParts = [ ...shadowParts ];
305+
newShadowParts[ index ] = part;
306+
onChange( newShadowParts.join( ', ' ) );
306307
};
307308

308309
const onAddShadowPart = () => {
309-
shadowParts.push( defaultShadow );
310-
onChange( shadowParts.join( ', ' ) );
310+
onChange( [ ...shadowParts, defaultShadow ].join( ', ' ) );
311311
};
312312

313313
const onRemoveShadowPart = ( index ) => {
314-
shadowParts.splice( index, 1 );
315-
onChange( shadowParts.join( ', ' ) );
314+
onChange( shadowParts.filter( ( p, i ) => i !== index ).join( ', ' ) );
316315
};
317316

318317
return (

0 commit comments

Comments
 (0)