title: How can I update react redux toolkit store using dispatch?
body: <p>I am tried to edit an object data of an array containing more than one object in react redux toolkit store with dispatch but it does not work. Also, I want to navigate to other component after dispatch similarly does not work . Although I was selected the item which I want to change by id using filter() method and update the state with action. payload it printed in the console exactly as I want but state still keeps old data.</p>
  <hr />
  <pre><code>import editUserAccountR from .............
  
          const updatedData = {
                        id,
                        name,
                        age,
                        lang,
                      };
          //old state contain the same properties
                      dispatch(editUserAccountR(updatedData));
                      navigate(&quot;/otherComponent&quot;);
                 //  -----------------------------------------------------
          store :
         // --------------------------------------
           editUserAccountR: (state, action) =&gt; {
                state.authorization.userAccounts =
                  state.authorization.userAccounts.filter((item) =&gt; {
                    if (item.id === action.payload.id) {
                      item = action.payload;
                    }
                    return item;
          //item updated successfully but state not
                  });`enter code here`
              },
  </code></pre>