title: `useSelector` rerenders even when the object is the same
body: <p>I am refactoring React app that was built using class syntax and <code>connect</code> to React hooks.</p>
  <p>App is meant to be for debugging and one of the bugs that has to be fixed is that in the reducer file we are not returning the new state object so the component doesn't rerender.</p>
  <pre class="lang-js prettyprint-override"><code>export default function comments(state = InitialState, action) {
    switch (action.type) {
      case &quot;CHANGE_SORT&quot;: {
        state.sort = action.sort;
        return state;
      }
  
      default:
        return state;
    }
  }
  </code></pre>
  <p>This doesn't cause the app to rerender so the state doesn't update and that is fine. However, once I refactored the app to use React hooks and <code>useSelector</code> the component rerenders even with this code. Is there a way I could make it not rerender unless the new state object is returned?</p>
  <p>This is how the store is setup:</p>
  <pre class="lang-js prettyprint-override"><code>  const store = createStore(
      combineReducers({
        posts,
        sort,
      }),
      {},
      applyMiddleware(thunkMiddleware)
    );
  </code></pre>