v2.0.0-alpha.5 #3382
markerikson
announced in
Announcements
v2.0.0-alpha.5
#3382
Replies: 1 comment
-
|
Really looking forward to this! Trying it out now, and bumping into a TS issue. Its quite common for us to use selectors within other selectors, like this for instance: When I do this though, the surveysSlice object itself gets the type "any". If I change to this, then the type is correct again: Should I register an issue for this, or is this not something you would expect to work? |
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 is an alpha release for Redux Toolkit 2.0. This release adds a new
combineSlicesAPI for reducer injection, has many changes to our build setup and published package contents, updates thereduxdep to the latest alpha, updates theimmerdep to 10.0 final, includes the latest changes from 1.9.x, and has breaking changes.Changelog
New
combineSlicesAPIThe Redux core has always included
combineReducers, which takes an object full of "slice reducer" functions and generates a reducer that calls those slice reducers. RTK'screateSlicegenerates slice reducers + associated action creators, and we've taught the pattern of exporting individual action creators as named exports and the slice reducer as a default export. Meanwhile, we've never had official support for lazy-loading reducers, although we've had sample code for some "reducer injection" patterns in our docs.This release includes a new
combineSlicesAPI that is designed to enable lazy-loading of reducers at runtime. It accepts individual slices or an object full of slices as arguments, and automatically callscombineReducersusing thesliceObject.namefield as the key for each state field. The generated reducer function has an additional.inject()method attached that can be used to dynamically inject additional slices at runtime. It also includes a.withLazyLoadedSlices()method that can be used to generate TS types for reducers that will be added later. See #2776 for the original discussion around this idea.For now, we are not building this into
configureStore, so you'll need to callconst rootReducer = combineSlices(.....)yourself and pass that toconfigureStore({reducer: rootReducer}).In addition, the existing
createSliceAPI now has support for definingselectorsdirectly as part of the slice. By default, these will be generated with the assumption that the slice is mounted in the root state usingslice.nameas the field, such asname: "todos"->rootState.todos. You can callsliceObject.getSelectors(selectSliceState)to generate the selectors with an alternate location, similar to howentityAdapter.getSelectors()works.We don't have documentation added for these features yet, but here's example usages from the
combineSlicesPR tests:Basic usage: a mixture of slices and standalone reducers passed to
combineSlicesBasic slice reducer injection
Slice selectors
Build Setup Updates
We've switched our build setup to use
tsup, an ESBuild-powered build framework. This release should have identical build artifacts to2.0.0-alpha.4, but let us know if there are any issues!Immer 10.0
Immer 10.0 is now final, and has several major improvements and updates:
We've updated RTK to depend on the final Immer 10.0 release .
Redux 5.0 alpha and TS types updates
We've updated RTK to use the latest Redux
5.0-alpha.5release, which tweaks theReducertype, drops the internal$CombinedStatetype, and updates middleware types to default tounknownfor actions.For RTK, we've improved type inference for store enhancers, especially those that add additional fields to the state or store.
What's Changed
tsupby @markerikson in Switch build setup from a custom ESBuild+TS script totsup#3362responseHandlerbeing used infetchBaseQueryby @praxxis in Fix globalresponseHandlerbeing used infetchBaseQuery#3137resetApiStateby @phryneas in reset internalState.currentSubscriptions onresetApiState#3333subscriptionUpdatedas autobatched by @markerikson in Bump deps and marksubscriptionUpdatedas autobatched #3364Full Changelog: v2.0.0-alpha.4...v2.0.0-alpha.5
This discussion was created from the release v2.0.0-alpha.5.
Beta Was this translation helpful? Give feedback.
All reactions