title: State JS object not persistent upon setState
body: <p>I have a state which looks like this.</p>
  <pre><code>let coinlist = {
      BTC:0,
      ETH:0,
      USDT:0,
      XRP:0,
      ADA:0,
      SOL:0,
      AVAX:0,
      DOT:0,
      DOGE:0,
      UST:0,
      SHIB:0,
      MATIC:0,
      WBTC:0,
      CRO:0,
      DAI:0,
      LTC:0,
      ATOM:0,
      LINK:0,
      UNI:0,
      BCH:0,
      XLM:0
  }
    const [currencies, setCurrencies] = useState(coinlist);
  
  </code></pre>
  <p>I am using a websocket which provides the real time price values of these currencies.
  My onmessage looks like this.</p>
  <pre><code> useEffect(() =&gt; {
    // ...code to set up &amp; configure the websocket
  
  ws.current.onmessage = (e) =&gt; {
        let data = JSON.parse(e.data);
        console.log(data)
        if (data.type !== &quot;ticker&quot;) {
          return;
        }
        setCurrencies({
            ...currencies,
            [data.product_id.replace(&quot;-USD&quot;,&quot;&quot;)]:data.price
        })
      };
    }, []);
  </code></pre>
  <p>Now, upon receiving every new price for any of the currencies from the ws, the setState only updates the particular currency, i.e the values are not persistent accross the setStates.
  The console.log looks something like this.</p>
  <pre><code>ADA: 0
  ATOM: 0
  AVAX: 0
  BCH: 0
  BTC: 0
  CRO: 0
  DAI: 0
  DOGE: 0
  DOT: 0
  ETH: 0
  LINK: 0
  LTC: &quot;125.07&quot;
  MATIC: 0
  SHIB: 0
  SOL: 0
  UNI: 0
  USDT: 0
  UST: 0
  WBTC: 0
  XLM: 0
  XRP: 0
  </code></pre>
  <p>and the next message looks like this.</p>
  <pre><code>ADA: 0
  ATOM: 0
  AVAX: 0
  BCH: 0
  BTC: &quot;43935.89&quot;
  CRO: 0
  DAI: 0
  DOGE: 0
  DOT: 0
  ETH: 0
  LINK: 0
  LTC: 0
  MATIC: 0
  SHIB: 0
  SOL: 0
  UNI: 0
  USDT: 0
  UST: 0
  WBTC: 0
  XLM: 0
  XRP: 0
  </code></pre>
  <p>What i am expecting is something like this.</p>
  <pre><code>BTC: &quot;43935.89&quot;
  SOL: &quot;10.56&quot;
  UNI: &quot;277&quot;
  USDT: &quot;25&quot;
  UST: &quot;105&quot;
  WBTC: &quot;200&quot;
  XLM: &quot;100.23&quot;
  XRP: &quot;0.5&quot;
  </code></pre>
  <p>Am i using the setCurrencies properly??</p>