v2.0.0-rc.0 #3890
markerikson
announced in
Announcements
v2.0.0-rc.0
#3890
Replies: 1 comment
-
|
This is great stuff. Nice release 👏 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This release candidate modifies the approach for defining async thunks inside of
createSlice, and improves several bits of usage and implementation around selectors.Note that we hope to release Redux Toolkit 2.0, Redux core 5.0, and React-Redux 9.0 by the start of December!. (If we don't hit that, we'll aim for January, after the holidays.)
See the preview Redux Toolkit 2.0 + Redux core 5.0 Migration Guide for an overview of breaking changes in RTK 2.0 and Redux core.
The 2.0 integration branch contains the docs preview for the 2.0 changes. Not all changes are documented yet, but you can see API reference pages for most of the new features here:
Changelog
Async Thunk and
createSlicechangesIn earlier alphas, we added the ability to define async thunks directly inside of
createSlice.reducers, using a callback syntax. However, that meant thatcreateSlicehad a hard dependency oncreateAsyncThunk, and importingcreateSlicewould always includecreateAsyncThunkin an app bundle even if it wasn't being used.In practice, we expect that most RTK users will use
createAsyncThunk, either directly or as part of RTK Query. But, we take bundle size seriously, and didn't want to force all uses ofcreateSliceto add the 2K forcreateAsyncThunkto a bundle if it isn't actually being used.Since we expect that defining thunks inside of
createSliceis a less-common use case, we've settled on a compromise. The standardcreateSlicemethod does not support callingcreate.asyncThunk()inside even if you use the callback syntax. Instead, you need to callbuildCreateSlice()to create a customized version ofcreateSlicewith the async thunk capabilities built in, and use that:Selector Changes
createSlicenow adds aselectSlicefield to all slice objects. This simple selector assumes that the slice has been added atrootState[slice.name](orrootState[slice.reducerPath]if defined). This is useful for basic lookups of the slice's state.entityAdapter.getSelectors()now accepts alternate selector creators with customized memoization options.What's Changed
createDraftSafeSelector. by @aryaemami59 in [RTK v2.0] output selector fields are currently missing in selector functions created usingcreateDraftSafeSelector. #3722settledandselectSliceto docs. by @EskiMojo14 in AddsettledandselectSliceto docs. #3882Full Changelog: v2.0.0-beta.4...v2.0.0-rc.0
This discussion was created from the release v2.0.0-rc.0.
Beta Was this translation helpful? Give feedback.
All reactions