title: React Redux - Invariant failed: A state mutation was detected inside a dispatch
body: <p>I'm receiving this error: <code>Invariant failed: A state mutation was detected inside a dispatch</code> and can't seem to find a solution for it. I'm fetching user support tickets via an API and saving it to a state in order to display the ticket information. Here is my code:</p>
  <pre><code>const initialState: stateType = {
      User: new User(),
      SupportTickets: new SupportTickets()
  }
  
  const userSlice = createSlice({
      name: &quot;User&quot;,
      initialState,
      reducers: {
          setUser: (state, {payload}) =&gt; {
              state.User = payload
          },
          setSupportTickets: (state, {payload}) =&gt; {
              state.SupportTickets.tickets = payload
          }
      }
  })
  
  export const {setUser, setSupportTickets} = userSlice.actions
  
  export const userSelector = (state: stateType) =&gt; state.User
  export const userSupportTicketsSelector = (state: stateType) =&gt; state.SupportTickets
  
  export function fetchSupportTickets(userId: string, token: string) {
      return async (dispatch: AppDispatch) =&gt; {
          return await fetch(API_URL, {
              method: 'GET',
              headers: {
                  Authorization: `Bearer ${token}`
              }
          }).then(response =&gt; {
              if (!response.ok) { throw response }
              return response.json()
          }).then(json =&gt; {
              dispatch(setSupportTickets(json))
          }).catch(error =&gt; {
              console.log('Failed to fetch support tickets', error);
          })
      }
  }
  
  interface stateType {
      User: User
      SupportTickets: SupportTickets
  }
  </code></pre>
  <pre><code>export class SupportTickets {
      tickets: SupportTicket[] = []
  }
  
  export class SupportTicket {
      id: number = 0
      type: string = &quot;&quot;
      subject: string = &quot;&quot;
      priority: string = &quot;&quot;
      status: string = &quot;&quot;
      created_at: string = &quot;&quot;
      updated_at: string = &quot;&quot;
  }
  </code></pre>
  <p>I've tried changing/moving things around without any success. Any help is greatly appreciated. Thanks in advance.</p>