From ae9db95750145767ef662e82a591992b5b1b5169 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Thu, 24 Oct 2024 22:34:56 +0900 Subject: [PATCH] Global Styles: Fix React Compiler variable mutation error (#66410) Co-authored-by: Mamaduka Co-authored-by: tyxla --- .../components/global-styles/shadows-edit-panel.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/shadows-edit-panel.js b/packages/edit-site/src/components/global-styles/shadows-edit-panel.js index af5f3445a5119..7321e927fbbae 100644 --- a/packages/edit-site/src/components/global-styles/shadows-edit-panel.js +++ b/packages/edit-site/src/components/global-styles/shadows-edit-panel.js @@ -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 (