chore(deps): update dependency @reduxjs/toolkit to v1.8.5 #1624
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
1.7.1
->1.8.5
Release Notes
reduxjs/redux-toolkit
v1.8.5
Compare Source
This bugfix releas fixes an issue with large
keepUnusedDataFor
values overflowing JS timers, exports the types for the Redux DevTools Extension option, and and improves behavior of URL string generation.Changelog
keepUnusedDataFor
Timer FixkeepUnusedDataFor
accepts a value in seconds. When there are no more active subscriptions for a piece of data, RTKQ will set a timer usingsetTimeout
, andkeepUnusedDataFor * 1000
as the timer value.We've been advising users that if they want to keep data in the cache forever that they should use a very large value for
keepUnusedDataFor
, such as 10 years in seconds.However, it turns out that JS engines use a 32-bit signed int for timers, and 32-bits in milliseconds is only 24.8 days. If a timer is given a value larger than that, it triggers immediately.
We've updated the internal logic to clamp the
keepUnusedDataFor
value to be between 0 andTHIRTY_TWO_BIT_MAX_TIMER_SECONDS - 1
.Note that in RTK 1.9 (coming soon), RTKQ will also accept
Infinity
as a specialkeepUnusedDataFor
value to indicate cached data should never be expired.Other Changes
RTK inlines the TS types for the Redux DevTools Extension options to avoid an extra dependency, but the TS type for the options object wasn't exported publicly. We now export the
DevToolsEnhancerOptions
type.The logic for generating a final URL has been updated to avoid adding an extra trailing
/
.What's Changed
keepUnusedDataFor
values from overflowingsetTimeout
counter by @markerikson in https://github.com/reduxjs/redux-toolkit/pull/2595Full Changelog: reduxjs/redux-toolkit@v1.8.4...v1.8.5
v1.8.4
Compare Source
This bugfix release adds exported TS types for RTKQ hooks for use in wrapping logic, adds
useDebugValue
to the hooks to improve display in the React DevTools, updates the inlined types for the Redux DevTools options, and fixes an issue increateEntityAdapter
that could result in duplicate IDs being stored.Changelog
RTKQ Hook Result Types
RTK's types heavily rely on inference to minimize the amount of type info users have to provide. However, this can also make it difficult to write functions that wrap calls to RTK APIs.
Some users have asked to have types that help them write "higher-order hooks". RTK now exports types that represent "the return object for a query/mutation hook with a given value":
TypedUseQueryHookResult
andTypedUseMutationResult
. Both require<ResultType, QueryArg, BaseQuery>
as generics, like this:Redux DevTools Options Fixes
As of Redux DevTools 3.0, some of field names for custom DevTools options have changed to
actionsAllowlist
andactionsDenylist
. Since we inline the types instead of having a separate dependency, we've updated our TS types to match that. No runtime behavior was changed.Other Changes
RTKQ hooks now use
useDebugValue
to give a better preview of the current value in the React DevTools "Component" tab.The
<ApiProvider>
component now does a better job of registering and cleaning up focus listeners.Fixed a bug with
createEntityAdapter
that could allow duplicate IDs to be added depending on update parameters.What's Changed
Full Changelog: reduxjs/redux-toolkit@v1.8.3...v1.8.4
v1.8.3
Compare Source
This bugfix release fixes a few minor issues and bits of behavior, including updating the React-Redux peer dep to
^8.0.2
final, stable sorting increateEntityAdapter.updateMany
and some initial state handling increateSlice
.Changelog
React-Redux Peer Dep
We'd previously published an RTK build that accepted React-Redux v8 beta as a peer dep (for use with RTK Query). Since React-Redux v8 is out now, we've updated the peer dep to
^8.0.2
.Entity Adapter Updates
Previously, applying updates via
createEntityAdapter.updateMany
caused sorting order to change. Entities that had the same sorting result should have stayed in the same order relative to each other, but if one of those items had any updates, it would sort to the back of that group. This was due to items being removed from the lookup table and re-added, and since JS engines iterate keys in insertion order, the updated item would now end up compared later than before.We've reworked the implementation of
updateMany
to avoid that. This also ended up fixing another issue where multiple update entries targeting the same item ID would only have the first applied.createSlice
Initial StatecreateSlice
now logs an error ifinitialState
isundefined
. This is most commonly seen when users misspellinitialState
. It also has better handling for values that can't be frozen by Immer such as primitives.RTK Query
Several assorted improvements, including TS types for
BaseQuery
and checking if the body can actually be safely stringified.What's Changed
updateMany
to ensure stable sorting order by @markerikson in https://github.com/reduxjs/redux-toolkit/pull/2464New Contributors
Full Changelog: reduxjs/redux-toolkit@v1.8.2...1.8.3
v1.8.2
Compare Source
This bugfix release fixes a minor issue where calling
listenerMiddleware.startListening()
multiple times with the sameeffect
callback reference would result in multiple entries being added. The correct behavior is that only the first entry is added, and later attempts to add the same effect callback reference just return the existing entry.What's Changed
Full Changelog: reduxjs/redux-toolkit@v1.8.1...v1.8.2
v1.8.1
Compare Source
This release updates RTK's peer dependencies to accept React 18 as a valid version. This should fix installation errors caused by NPM's "install all the peer deps and error if they don't match" behavior.
React-Redux and React 18
Note: If you are now using React 18, we strongly recommend using the React-Redux v8 beta instead of v7.x!. v8 has been rewritten internally to work correctly with React 18's Concurrent Rendering capabilities. React-Redux v7 will run and generally work okay with existing code, but may have rendering issues if you start using Concurrent Rendering capabilities in your code.
Now that React 18 is out, we plan to finalize React-Redux v8 and release it live within the next couple weeks. We would really appreciate final feedback on using React-Redux v8 beta with React 18 before we publish the final version.
v1.8.0
Compare Source
This release adds the new "listener" middleware, updates
configureStore
's types to better handle type inference from middleware that overridedispatch
return values, and updates our TS support matrix to drop support for TS < 4.1.Changelog
New "Listener" Side Effects Middleware
RTK has integrated the thunk middleware since the beginning. However, thunks are imperative functions, and do not let you run code in response to dispatched actions. That use case has typically been covered with libraries like
redux-saga
(which handles side effects with "sagas" based on generator functions),redux-observable
(which uses RxJS observables), or custom middleware.We've added a new "listener" middleware to RTK to cover that use case. The listener middleware is created using
createListenerMiddleware()
, and lets you define "listener" entries that contain an "effect" callback with additional logic and a way to specify when that callback should run based on dispatched actions or state changes.Conceptually, you can think of this as being similar to React's
useEffect
hook, except that it runs logic in response to Redux store updates instead of component props/state updates.The listener middleware is intended to be a lightweight alternative to more widely used Redux async middleware like sagas and observables. While similar to thunks in level of complexity and concept, it can replicate some common saga usage patterns. We believe that the listener middleware can be used to replace most of the remaining use cases for sagas, but with a fraction of the bundle size and a much simpler API.
Listener effect callbacks have access to
dispatch
andgetState
, similar to thunks. The listener also receives a set of async workflow functions liketake
,condition
,pause
,fork
, andunsubscribe
, which allow writing more complex async logic.Listeners can be defined statically by calling
listenerMiddleware.startListening()
during setup, or added and removed dynamically at runtime with specialdispatch(addListener())
anddispatch(removeListener())
actions.The API reference is available at:
https://redux-toolkit.js.org/api/createListenerMiddleware
Huge thanks to @FaberVitale for major contributions in refining the middleware API and implementing key functionality.
Basic usage of the listener middleware looks like:
You can use it to write more complex async workflows, including pausing the effect callback until a condition check resolves, and forking "child tasks" to do additional work:
configureStore
Middleware Type ImprovementsMiddleware can override the default return value of
dispatch
.configureStore
tries to extract any declareddispatch
type overrides from themiddleware
array, and uses that to alter the type ofstore.dispatch
.We identified some cases where the type inference wasn't working well enough, and rewrote the type behavior to be more correct.
TypeScript Support Matrix Updates
RTK now requires TS 4.1 or greater to work correctly, and we've dropped 4.0 and earlier from our support matrix.
Other Changes
The internal logic for the serializability middleware has been reorganized to allow skipping checks against actions, while still checking values in the state.
What's Changed
Since most of the implementation work on the middleware was done over the last few months, this list only contains the most recent PRs since 1.7.2. For details on the original use case discussions and the evolution of the middleware API over time, see:
PRs since 1.7.2:
Full Changelog: reduxjs/redux-toolkit@v1.7.2...v1.8.0
v1.7.2
Compare Source
This release fixes a TS types bug with RTK Query generated selectors, makes the RTKQ structural sharing behavior configurable, adds an option to have the serializability middleware ignore all actions, and has several minor bugfixes and enhancements to RTK Query.
Changelog
RTK Query Selector TS Types Fix
Several users had reported that as of 1.7.0 selectors generated via
apiSlice.endpoint.select()
were failing to compile when used, with TS errors that looked likeType '{}' is missing the following properties from type 'CombinedState<>
.We've fixed the issue, and selectors should now compile correctly when used with TS.
Additional Configuration Options
RTK Query implements a technique called "structural sharing" to preserve existing object references if possible when data for an endpoint is re-fetched. RTKQ recurses over both data structures, and if the contents appear to be the same, keeps the existing values. That helps avoid potential unnecessary re-renders in the UI, because otherwise the entire re-fetched result would be new object references.
However, this update process can potentially take time depending on the size of the response. Endpoints can now be given a
structuralSharing
option that will turn that off to save on processing time:Additionally, the serializability check middleware can now be customized with an
ignoreActions
option to exempt all actions from being checked. This is an escape hatch and isn't recommended for most apps:Other API Improvements
If an
extraArgument
was provided to the thunk middleware during store configuration, that value is now passed along to theprepareHeaders()
function:The
invalidatesTags/providesTags
functions now receive theaction.meta
field as an argument, to help with potentially invalidating based on request/response headers.Bug Fixes
refetchOnFocus
now cleans up cache entries if a focus event is received and there are no active subscriptions, to avoid unnecessary requests.Active polls are cleaned up when the last component for a given subscription unsubscribes.
The types for
builder.addMatcher
have been updated to support inference of guards without atype
property.What's Changed
addMatcher
typings by @crcarrick in https://github.com/reduxjs/redux-toolkit/pull/1895extra
toprepareHeaders
, update documentation + tests by @msutkowski in https://github.com/reduxjs/redux-toolkit/pull/1922reducerPath
for query definitions by @phryneas in https://github.com/reduxjs/redux-toolkit/pull/1977ignoreActions
flag to serializable state middleware by @msutkowski in https://github.com/reduxjs/redux-toolkit/pull/1984structuralSharing
on endpoints/queries/createApi by @msutkowski in https://github.com/reduxjs/redux-toolkit/pull/1954Full Changelog: reduxjs/redux-toolkit@v1.7.1...v1.7.2
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.