title: Wordpress Gutenberg: Attribute overwritten by block duplicate
body: <p>For a custom wordpress gutenberg block I've created a list of buttons so that users can add/remove as many as needed. While this works pretty fine one issue occurs: When duplicating a block the duplicate overwrites the array values of the origin block as long as we are in editing mode. After saving and refreshing the page the array values become independent. Is anyone aware of that behaviour?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// Simplified code:
  
  // Attributes definition:
  ...
  attributes: {
    buttons: {
      type: 'array',
      default: []
    }
  }
  ...
  const buttons = props.attributes.buttons
  ...
  // Edit inspector controls:
  buttons.length &gt; 0 &amp;&amp; buttons.map( function( button, index ) {
    return el(
      TextControl,
      {
        label: 'Text',
        value: button.text,
        onChange: function( newText ) {
          let newButtons = [ ...buttons ]
          newButtons[ index ][ 'text' ] = newText
  
          props.setAttributes( { buttons: newButtons } )
        }
      }
    )
  }
  
  // Edit / Save output:    
  buttons.length &gt; 0 &amp;&amp; buttons.map( function( button, index ) {
    return el(
      'a',
      {
        key: 'button-' + index        
      },
      button.text
    )
  } )</code></pre>
  </div>
  </div>
  </p>