Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: bump @reduxjs/toolkit from 2.2.8 to 2.3.0 in /typescript (#2378)
Bumps [@reduxjs/toolkit](https://github.com/reduxjs/redux-toolkit) from 2.2.8 to 2.3.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/reduxjs/redux-toolkit/releases"><code>@reduxjs/toolkit</code>'s releases</a>.</em></p> <blockquote> <h2>v2.3.0</h2> <p>This <strong>feature release</strong> adds a new RTK Query <code>upsertQueryEntries</code> util to batch-upsert cache entries more efficiently, passes through additional values for use in <code>prepareHeaders</code>, and exports additional TS types around query options and selectors.</p> <h2>Changelog</h2> <h3><code>upsertQueryEntries</code></h3> <p>RTK Query already had an <code>upsertQueryData</code> thunk that would upsert a single cache entry. However, some users wanted to upsert <em>many</em> cache entries (potentially hundreds or thousands), and found that <code>upsertQueryData</code> had poor performance in those cases. This is because <code>upsertQueryData</code> runs the full async request handling sequence, including dispatching both <code>pending</code> and <code>fulfilled</code> actions, each of which run the main reducer and update store subscribers. That means there's <code>2N</code> store / UI updates per item, so upserting hundreds of items becomes extremely perf-intensive.</p> <p>RTK Query now includes an <code>api.util.upsertQueryEntries</code> action that is meant to handle the batched upsert use case more efficiently. It's a single synchronous action that accepts an array of many <code>{endpointName, arg, value}</code> entries to upsert. This results in a single store update, making this vastly better for performance vs many individual <code>upsertQueryData</code> calls.</p> <p>We see this as having two main use cases. The first is prefilling the cache with data retrieved from storage on app startup (and it's worth noting that <code>upsertQueryEntries</code> can accept entries for many different endpoints as part of the same array).</p> <p>The second is to act as a "pseudo-normalization" tool. <a href="https://redux-toolkit.js.org/rtk-query/usage/cache-behavior#no-normalized-or-de-duplicated-cache">RTK Query is <em>not</em> a "normalized" cache</a>. However, there are times when you may want to prefill other cache entries with the contents of another endpoint, such as taking the results of a <code>getPosts</code> list endpoint response and prefilling the individual <code>getPost(id)</code> endpoint cache entries, so that components that reference an individual item endpoint already have that data available.</p> <p>Currently, you can implement the "pseudo-normalization" approach by dispatching <code>upsertQueryEntries</code> in an endpoint lifecycle, like this:</p> <pre lang="ts"><code>const api = createApi({ endpoints: (build) => ({ getPosts: build.query<Post[], void>({ query: () => '/posts', async onQueryStarted(_, { dispatch, queryFulfilled }) { const res = await queryFulfilled const posts = res.data <pre><code> // Pre-fill the individual post entries with the results // from the list endpoint query dispatch( api.util.upsertQueryEntries( posts.map((post) =&gt; ({ endpointName: 'getPost', arg: { id: post.id }, value: post, })), ), ) }, }), getPost: build.query&lt;Post, Pick&lt;Post, 'id'&gt;&gt;({ query: (post) =&gt; `post/${post.id}`, }), </code></pre> <p>}),<br /> })<br /> </code></pre></p> <p>Down the road we may add a new option to query endpoints that would let you provide the mapping function and have it automatically update the corresponding entries.</p> <p>For additional comparisons between <code>upsertQueryData</code> and <code>upsertQueryEntries</code>, see <a href="https://redux-toolkit.js.org/rtk-query/api/created-api/api-slice-utils#upsertqueryentries">the <code>upsertQueryEntries</code> API reference</a>.</p> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/reduxjs/redux-toolkit/commit/77fb33d280a2020fffee4049f8b6a5b823092bb6"><code>77fb33d</code></a> Release 2.3.0</li> <li><a href="https://github.com/reduxjs/redux-toolkit/commit/fa0906e691dec28ff66b4e37eff3a8ed51957423"><code>fa0906e</code></a> Merge pull request <a href="https://redirect.github.com/reduxjs/redux-toolkit/issues/4291">#4291</a> from reduxjs/pr/fetchBaseQuery-extraOptions</li> <li><a href="https://github.com/reduxjs/redux-toolkit/commit/896e4dfa020115cd2b03f5fb360578f7d11c43b3"><code>896e4df</code></a> Drop generic and make extraOptions unknown</li> <li><a href="https://github.com/reduxjs/redux-toolkit/commit/41487fd8d436b1d05708a373308c6009675876a8"><code>41487fd</code></a> Fix arguments type</li> <li><a href="https://github.com/reduxjs/redux-toolkit/commit/1918f13ae4a806d2c775d3c06531cabb8ff3eb5a"><code>1918f13</code></a> fix bad inference with an overload?</li> <li><a href="https://github.com/reduxjs/redux-toolkit/commit/6ef362f4e74647870cd59f22a8afaf00059729aa"><code>6ef362f</code></a> fixup test</li> <li><a href="https://github.com/reduxjs/redux-toolkit/commit/3e77381cfd89c6ee352aba72614babd0d617bf27"><code>3e77381</code></a> fetchBaseQuery: expose extraOptions to prepareHeaders</li> <li><a href="https://github.com/reduxjs/redux-toolkit/commit/7b50a610eb81ef11beb8111039bbd152ea5419b9"><code>7b50a61</code></a> Merge pull request <a href="https://redirect.github.com/reduxjs/redux-toolkit/issues/4561">#4561</a> from reduxjs/feature/4106-rtkq-normalization</li> <li><a href="https://github.com/reduxjs/redux-toolkit/commit/3358c1371e6225b069cf68f5ecdef34141e08676"><code>3358c13</code></a> Fix Parameters headers</li> <li><a href="https://github.com/reduxjs/redux-toolkit/commit/d38ff98c0b5569c8167c951fc2af6f2845911840"><code>d38ff98</code></a> Merge pull request <a href="https://redirect.github.com/reduxjs/redux-toolkit/issues/4638">#4638</a> from kyletsang/prepareheaders-args</li> <li>Additional commits viewable in <a href="https://github.com/reduxjs/redux-toolkit/compare/v2.2.8...v2.3.0">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=@reduxjs/toolkit&package-manager=npm_and_yarn&previous-version=2.2.8&new-version=2.3.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
- Loading branch information