title: React Redux, Am I mutating state here?
body: <p>I am playing around with a simple React Redux app that increments a counter each time a button is clicked.  I am testing two different methods of incrementing my counter in my Redux Reducer.  Both methods are changing the state in the reducer however one of these methods is not causing my counter to rerender.</p>
  
  <p>Here is the reducer which will cause the page to rerender:</p>
  
  <pre><code>const reducer = (state={speed: 0}, action) =&gt; {
  
    if(action.type ==='INCREMENT_SPEED'){
      state = {...state, speed: state.speed+=1 
      }
      return state 
  }
  </code></pre>
  
  <p>and here is the code that functions but will not cause the page to rerender with the proper value.</p>
  
  <pre><code>const reducer = (state={speed: 0}, action) =&gt; {
  
        if(action.type ==='INCREMENT_SPEED'){
          state.speed++ 
      }
      return state 
  }
  </code></pre>
  
  <p>The only difference is the way in which I am updating state.  My guess is that using the ++ incrementer is actually mutating state which is not seen as a change and hence does not cause the page to render.</p>
  
  <p>If it helps here is the part of the code that appends to the DOM:</p>
  
  <pre><code>render() {
      return (
        &lt;div&gt;
  
          &lt;p&gt;SPEED: {this.props.reduxState.reducer.speed}&lt;/p&gt;
  
        &lt;/div&gt;
      )
    }
  }
  </code></pre>