title: How can I get my Redux useSelector to update on store change?
body: <p>I'm using the Redux Toolkit and I'm struggling to find a way to update state within my store that also triggers a reassignment for useSelector.</p>
  <pre class="lang-js prettyprint-override"><code>const slice = createSlice({
    name: &quot;state&quot;,
    initialState: [],
    reducers: {
      addToArray: (state, action) =&gt; {
        state.push(action.payload); // This updates the store but doesn't respect immutability?
     }
   }
  });
  </code></pre>
  <p>I'm aware the above isn't entirely correct, and that something like</p>
  <p><code>state = [...state, ...action.payload]</code></p>
  <p>would be better, BUT for some reason I couldn't get it work correctly any other way. I'm simply trying to add an object to the array.</p>
  <p>My component:</p>
  <pre class="lang-js prettyprint-override"><code>export default function App() {
     const array = useSelector(selectArray);
  
     return (
       {array.map((x) =&gt; {
          &lt;div&gt;{x.text}&lt;/div&gt;
       })
     )
  }
  </code></pre>
  <p>The issue is, whenever the dispatch is called, <code>array</code> doesn't update, which I'd like it to.</p>