redux-toolkit icon indicating copy to clipboard operation
redux-toolkit copied to clipboard

RTK 1.8 and 1.9 planning

Open markerikson opened this issue 3 years ago • 18 comments

This was originally "1.8 planning", but 1.8 ended up just having the listener middleware. So, keeping the issue around for both.

1.8:

  • TS fixes for configureStore and getDefaultMiddleware
  • Merge in the listener middleware

Initial notional items for 1.9:

  • Drop support for TS < 4.1
  • Actual string literal types for createSlice

What else would we want to get in?

Existing milestone: https://github.com/reduxjs/redux-toolkit/milestone/7

Looking through the issues, other candidates:

  • Could go in a 1.8.x:
    • #1853 / #1860
  • Probably 1.9:
    • #1720
    • #1668
    • #1139
    • #975
    • #1059

For the record, I think this probably ought to be the last feature release before we look at doing RTK 2.0 and dropping IE11 compat ( ref: #958 )

markerikson avatar Feb 05 '22 20:02 markerikson

maybe a cAT.pinTypes/typeFactory thing?

phryneas avatar Feb 05 '22 21:02 phryneas

Unrelated but as a note for later: we should link the RTKQ "Essentials" tutorial pages from the RTKQ "Overview" page:

https://www.reddit.com/r/webdev/comments/sc6eoc/redux_toolkit_query_is_no_one_using_it/

markerikson avatar Feb 06 '22 22:02 markerikson

Another docs suggestion (possibly for me to implement): add more info/examples about dealing with errors. In particular, explaining the difference between a fetch error and serialized JavaScript error. https://stackoverflow.com/questions/70899492/redux-toolkit-do-not-send-request-when-query-param-is-invalid/71002555?noredirect=1#comment125554343_71002555

lindapaiste avatar Feb 13 '22 19:02 lindapaiste

@lindapaiste that would be a very welcome contribution!

phryneas avatar Feb 13 '22 21:02 phryneas

Throwing this here for lack of anywhere better:

https://www.reddit.com/r/reactjs/comments/q6lit4/thoughts_about_redux_reactquery_together/i0s3f27/

One thing i found that it needs extra config is SSR, if you are planning on doing SSR with something like Next for example, then you need to setup next-redux-wrapper and split your state, and combining reducers with the apiSlice while also supporting a global HYDRATE action to sync up server state with client state was a bit of a pain, we had to set a reducer case for HYDRATE for each slice, which can get big.

RTK Query looks promising but SSR is certainly a bit more painful compared to the "initialData" approach of react-query, one thing i do like is that you can still use endpoints defined within your apiSlice on the server instead of custom fetch functions.

Also a quick note about that, if you are working with a custom api fetch library that handles all your endpoint calls, its a bit hard to integrate that with query builders in RTK Query, RTK Query seems like a great option if you are using axios or fetch to build your data fetching side of the app from the ground. If you have something custom built already around some fetching library to handle your endpoint calls, then you will probably need to work some sort of integration between RTK Query and your library, react-query is a bit more detached from what you end up using as a fetcher.

markerikson avatar Mar 15 '22 21:03 markerikson

We should also deprecate the object notation of extraReducers and createReducer so we can remove it in 2.0.

I did some experiments - while removing is not a problem, deprecating the extraReducers object notation seems impossible. It would require adding a second overload to createSlice and that breaks half the inference (seems to be a TS quirk). So I would suggest deprecating it with a runtime warning in dev instead.

phryneas avatar Apr 24 '22 09:04 phryneas

If @FaberVitale can pull off the Suspense support in #2245 , that would presumably be 1.9 as well.

markerikson avatar Apr 24 '22 16:04 markerikson

If @FaberVitale can pull off the Suspense support in #2245 , that would presumably be 1.9 as well.

We need to upgrade react, react-redux, react-dom & @types/react to react 18 versions:

https://github.com/reduxjs/redux-toolkit/blob/0050738d8da05de46206cb134d2f90f3af5cb00e/package.json#L43

Are there features in the codebase that need useSyncExternalStore?

IIRC there was an issue with ApiProvider: https://github.com/reduxjs/redux-toolkit/blob/0050738d8da05de46206cb134d2f90f3af5cb00e/packages/toolkit/src/query/react/ApiProvider.tsx#L48

FaberVitale avatar Apr 24 '22 16:04 FaberVitale

Hmm. That is going to make versioning interesting :)

Given that the rest of RTKQ's features work with any version of React that has hooks... maybe we accept a React peer range of 16.8+, but have a runtime dev check in the suspense functionality that throws an error if it isn't a high enough React version?

Also we may need to update all of our examples and tests to work under React 18 as well.

And yeah, that line in ApiProvider should really be in an effect

markerikson avatar Apr 24 '22 17:04 markerikson

I opened a PR for that ApiProvider bug.

phryneas avatar Apr 24 '22 18:04 phryneas

@markerikson @phryneas I've made an additive feature request in https://github.com/reduxjs/redux-toolkit/issues/2355 and if 1.8 and 1.9 are possibly going to be the last releases before 2.0 then I'd like to ping y'all to get some priority feedback on it.

I don't know how big of an effort it would be, but if it's a feature that you'd support adding to RTK Query - I'm willing to take a stab at implementing it.

AlexeiDarmin avatar May 25 '22 19:05 AlexeiDarmin

I have opened a discussion https://github.com/reduxjs/redux-toolkit/discussions/2361#discussioncomment-2838605

The requested feature : giving an option (optional) in such a way as to skip the automated-invalidation for the last-focused query (only) while setting automated-invalidation in the mutation definition.

toggleFieldOfUser: builder.mutation<boolean, string>({
 query: (id) => ({
    url: `/users/${id}`,
    method: "PUT",
}),
invalidatesTags: cacher.cacheByIdArg("User"),  // <-----------------------  this will remain !
skipAutomatedInvalidationForLastFocusedQuery: true;   // <---------------  additional option (optional)
transformResponse: (result: { success: true }) => result.success,
async onQueryStarted(arg, { dispatch, queryFulfilled, getState }) {
   // manual cache update implementation.  <--- just for the last-focused query, we will deal with ourself
}

talatkuyuk avatar May 30 '22 13:05 talatkuyuk

If @FaberVitale can pull off the Suspense support in #2245 , that would presumably be 1.9 as well.

We need to upgrade react, react-redux, react-dom & @types/react to react 18 versions:

https://github.com/reduxjs/redux-toolkit/blob/0050738d8da05de46206cb134d2f90f3af5cb00e/package.json#L43

The React 18 upgrade is live here: https://github.com/reduxjs/redux-toolkit/pull/2409

#2409 is partially for maintenance but it also required for https://github.com/reduxjs/redux-toolkit/pull/2245

FaberVitale avatar Jun 12 '22 14:06 FaberVitale

Created PR https://github.com/reduxjs/redux-toolkit/pull/2420

Closes https://github.com/reduxjs/redux-toolkit/issues/2395 Pass abort reason of thunk action to AbortController

FaberVitale avatar Jun 16 '22 21:06 FaberVitale

Pasting notes from today's triage call:

  • #2363: hand-edit weird return logic and merge
  • #2362: we should do more docs edits to show that base queries can accept an object, and equivalence between objects and string URLs
  • #2308: add Immer+TS readonly and castDraft() description to "Usage with Immer" page
  • #2303: Need to move from packages/toolkit/codemod/ to packages/codemod/; also needs a CLI; should be listed in the 2.0 release notes
  • #2276: show TS example of the typed query hook type
  • need to merge next and v1.9-integration together
  • going to drop TS <4.1 support
  • #2250: needs rebase and conflict fixes, can merge into 1.9
  • #2239: needs re-reading for wording checks; add documentation with a use case
  • #2143: done, just fix conflicts
  • #2133: wrong idea; don't want an unsubscribe, instead should have a reset
  • #1938: needs reworking; Matt
  • #1910: needs docs rewording; Matt
  • #1931: needs reworking; Matt
  • #1841: needs reworking; Matt

Also, not 1.9 related, but:

  • Have some kind of Suspense Cache usage discussion with the React and React Query teams?

markerikson avatar Jul 03 '22 22:07 markerikson

Status notes from Lenz:

  • https://github.com/reduxjs/redux-toolkit/pull/2239 needs a type change to allow for either maxRetries or condition as an argument, but not both - and then remove passing maxRetries into the condition arguments. and maybe another look at the docs

  • https://github.com/reduxjs/redux-toolkit/pull/2187 seems good but might need a conflict resolve and rerun of the tests

  • https://github.com/reduxjs/redux-toolkit/pull/1841 looks essentially good for merging, but please take another look, four eyes see more than two 🙂

markerikson avatar Aug 15 '22 14:08 markerikson

Afraid I didn't do anything on this for about a month - been playing lots of golf, and work's been busy. But, golf season is coming to an end, and I want to pick this up and push it through soon.

I've got tomorrow free and Monday off, and I intend to focus on RTK 1.9 work.

markerikson avatar Oct 08 '22 02:10 markerikson

Working to collect a list of all the actual PRs that have gone into the 1.9 branch so I can figure out what needs to be documented and how to organize 1.9 release notes, and there's a lot :)

Up to date through #2768 .

The major outstanding code item is #2477 and nailing down an alternative API for getting operation promises. Beyond that we also need updated docs, and the release notes will need to provide instructions on running the codemods. (Probably should put the object reducer deprecation as the very first item in the release notes...)

RTK Query Features

  • #2493
    • #2835
  • #1059
  • #1841
  • #2266
    • #2646
    • #2669
  • #2663
    • #2844
  • Internal RTKQ rewrites:
    • #2599
    • #2641
    • #2644
    • #2757
    • #2759
    • #2850
    • #2856

RTKQ Minor Changes

  • fetchBaseQuery:
    • #2403
    • #2143
    • #2331
    • #2363
    • #2775
    • #2823
  • #2187
  • #2212
  • #2239
    • #2743

TS Types and Tweaks

  • #2250
  • #2550
  • #2604
  • #2643
  • Exports:
    • #2276
    • #1646
    • #2451
    • #2740
    • #2750

Other

  • #2591
    • #2602
    • #2768

markerikson avatar Oct 15 '22 02:10 markerikson

LIVE!

https://github.com/reduxjs/redux-toolkit/releases/tag/v1.9.0

markerikson avatar Nov 04 '22 14:11 markerikson