title: How do I deep clone an object in React?
body: <pre><code>let oldMessages = Object.assign({}, this.state.messages);
  // this.state.messages[0].id = 718
  
  console.log(oldMessages[0].id);
  // Prints 718
  
  oldMessages[0].id = 123;
  
  console.log(this.state.messages[0].id);
  // Prints 123
  </code></pre>
  
  <p>How can I prevent <code>oldMessages</code> to be a reference, I want to change the value of <code>oldMessages</code> without changing the value of <code>state.messages</code></p>