title: When are you required to use reacts prevState?
body: <p>Lets say whe have this state</p>
  
  <pre><code>state = {
    name: 'Daniel',
    fruits: {
      one: 'Banana',
      two: 'Apple'
    }
  }
  </code></pre>
  
  <p>I could update this with</p>
  
  <pre><code>this.setState({
    fruits: {
      ...this.state.fruits,
      one: 'Pineapple'
    }
  })
  </code></pre>
  
  <p>or i could do</p>
  
  <pre><code>this.setState(prevState =&gt; ({
    fruits: {
      ...prevState.fruits,
      one: 'Pineapple'
    }
  }))
  </code></pre>
  
  <p>I understand that if you have a counter that should be incremented, it would be a good idea to make sure you're incrementing from the previous state. But if we are changing a name and don't care about the previous name. Is there any benefit of using prevState in that case?</p>
  
  <p>Do you only need to use prevState if you're actually calculating something based on the previous state? In this case, we are spreading the fruits object. Could this object been changed in another call simultaniously and the version without prevState overriding it? (Do i always have to use prevState when handling objects in state?)</p>