React cloneElement not setting key

from the docs React.cloneElement

Unlike React.addons.cloneWithProps, key and ref from the original element will be preserved.

So if you set key for Cell, than each clone get key automaticaly.


One way to overcome this is to wrap each cloned element with React.Fragment and set the key on the latter.

Like so:

  <>
    {connections.map(connection => (
      <React.Fragment key={connection.id}>
        {React.cloneElement(element, connection)}
      </React.Fragment>
    ))}
  </>