Skip to content

Commit

Permalink
fix: React Query updateInPaginatedStore helper function not working…
Browse files Browse the repository at this point in the history
… as expected (#10249)

* fix trying to mutate the same array

* fix variable name

---------

Co-authored-by: Banks Nussman <banks@nussman.us>
  • Loading branch information
bnussman-akamai and bnussman authored Mar 4, 2024
1 parent 661f074 commit 6d22d36
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/manager/src/queries/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,17 @@ export const updateInPaginatedStore = <T extends { id: number | string }>(
return oldData;
}

oldData.data[toUpdateIndex] = {
const updatedPaginatedData = [...oldData.data];

updatedPaginatedData[toUpdateIndex] = {
...oldData.data[toUpdateIndex],
...newData,
};

return oldData;
return {
...oldData,
data: updatedPaginatedData,
};
}
);
};
Expand Down

0 comments on commit 6d22d36

Please sign in to comment.