-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React-Redux Roadmap: version 8.x, React 18, and TypeScript #1740
Comments
Are we wanting to make v8 only support React 18 or do we want to try for backwards compat? I'm fine with making a hard cutover and continuing to support 7.x as long as there are bug fixes (like we've done with 5.x and 4.x in the past). I'm not even sure if there's a BC path for |
Yeah, that's a great point. Using either So, yes, we'll need to maintain v7 for use with React 16/17. Fortunately, v7 is very stable at this point and I don't expect much if any future work will be needed on it. |
Some other points to consider: what about file formats in our published package? If you look at the current output ( https://unpkg.com/browse/[email protected]/ ), we've got these formats:
The Redux core is a similar setup. Meanwhile, for RTK ( https://unpkg.com/browse/@reduxjs/[email protected]/dist/ ), we've got a totally different setup:
There's also the question of adding an So, some questions:
|
Update: just had a good conversation with the React team, and the one-line summary is that they're going to rework This should hopefully pave the way for a fairly smooth migration path for React-Redux itself, and allow us to keep the same public-facing API so that our end users can update with minimal changes needed. Some notes on the discussion are here: |
I'd originally planned that v8 would have a hard dependency on React 18, even though the Earlier today someone suggested that we could try adding a This would also have the benefit of keeping React-Redux potentially working with Preact, since I don't think they've tried to implement |
Now that React 18 is GA, should updates to using concurrent features be expected? |
Not sure what you mean by "updates to using concurrent features" - can you clarify? FWIW I think that the current Ideally I'd like to publish v8 live within the next couple weeks, but it depends on how much time I can put into it and if there's any other tweaks that need to be made. There were some suggested SSR examples linked over in the PR that would make potential starting points: |
Still not 100% sure I understand what's being asked :) I would certainly expect parts of the React community to begin updating to React 18, and then start using features like But I'm not sure I follow how that ties into this thread specifically. |
So there's a couple complications this morning. Turns out that creating a new CRA project with a Redux template is now failing, because CRA tries to install the latest React as a default, and NPM now force-installs peer deps and throws errors if it can't match. So, it installs React 18, then tries React-Redux v7, sees that v7 only supports React 17, and errors. This unfortunately brings up several issues, though.
I've pinged the React team to see if they have thoughts, and will try to sort this out shortly. |
I've put out React-Redux 7.2.7 as a stopgap, which bumps the peer dep to include |
Talked about this with the React team today, and they advised to go ahead and use the shim by default. So, in the next couple days I'm going to ship a new React-Redux v8 beta that flips the current setup:
This has a few implications:
|
8.0.0-beta.4 is available with the change to use the shim by default: https://github.com/reduxjs/react-redux/releases/tag/v8.0.0-beta.4 |
According to https://github.com/dai-shi/will-this-react-global-state-work-in-concurrent-rendering, there seems to be a few use cases with react-redux |
(And, it's totally expected.) |
@TheHolyWaffle That's expected, really. Per reactwg/react-18#70 , libraries with external mutable stores are not expected to have "full 100% absolute perfect" compat with Concurrent rendering, even with Additionally, as much as @dai-shi has done amazing work on that benchmark, Andrew pointed out at #1808 (comment) that the benchmark's capabilities are somewhat limited anyway. So, switching over to use |
React-Redux v8 is out, so I think we can call this done :) |
Should |
@geekact : no, because React-Redux v8 can still be used with React 16 and 17, which do not have automatic batching. |
I want to start sketching out the likely direction for React-Redux version 8. (I'll refer to it as "v8" for shorthand - please note that I'm referring to our next major version, and not the JS engine :) )
Unlike our giant v7 effort captured in the v7 roadmap issue and the many v7.1 hooks issues, I expect that v8 will be simpler in terms of conceptual changes and design work. On the other hand, it's also possible it might end up involving a significant amount of total effort.
For now, I just want to list what I think are the big-ticket items for a v8 major version.
Planned Major Changes
React 18 and Concurrent Compatibility
We have numerous prior threads discussing how React-Redux will work with React's eventual Concurrent features. A lot of that has involved speculation and hypotheticals because of the long drawn-out development process for Suspense and Concurrent React. Now that React 18 alpha has been announced, it looks like A) the new behaviors are finally about to become reality, B) we have some more concrete ideas of what APIs exist and what the potential issues are, and C) the React team is trying to share info and prepare the ecosystem over in the React 18 Working Group.
While we don't have a final concrete plan for what will happen, most likely React-Redux v8 will:
useSelector
andconnect
)useMutableSource
as an integration layer to provide better compatibility with Concurrent rendering. (It's also possible that we could look at context-based approaches again if React finalizes a "context selectors" API and makes that available.)TypeScript
The three major Redux libraries have all followed different paths for TS usage and development:
We do have a still-unreleased conversion of the Redux core lib sitting in its
master
branch. It's been there for a while, and tbh we still don't have specific plans to release that any time soon. There's a bunch of factors around ecosystem compat and churn we'd need to consider first.The React-Redux typedefs are incredibly complex, and I'd like to give kudos to everyone who's built them up over the years. In particular, the handling of the various
connect
overloads is really complicated, which isn't surprising when you consider the number of optional parameters and overloads it has.But, if we're going to be doing a major version, we ought to go ahead and rewrite the React-Redux source in TS, so that we can stop having to deal with separate typedefs.
Code Cleanup
The primary breaking change here will be the planned removal of the
connectAdvanced
API. It was part of the original v5 implementation, largely because the author of v5 wanted more flexibility than the existingconnect
API offered. A few other folks used it, but ultimately it saw very little use. In addition, our hooks API has effectively addressed those use cases.We announced it would be deprecated a couple years ago. While we never formally slapped a
// @deprecated
tag on it, the description's been there for a while. Consolidating the logic forconnect
andconnectAdvanced
will probably simplify things a bit.We'll see what else we can clean up in the process.
Other Changes?
I don't immediately have anything else specific intended for v8 off the top of my head. I still like the idea of some Proxy-based selector handling ala #1653 , but it seems like that should be addressed more as a general Redux usage thing than building something directly into React-Redux
Timeline
No idea! :)
Okay, so we're sorta inching towards that now. I'm participating in the React 18 Working Group discussions, and they've emphasized that they want to help the ecosystem improve compat leading up to a live React 18 release. So, this is coming, but no hard dates.
Meanwhile, I've requested help from the community in migrating the current codebase to TS, as a foundation before we do any attempted compat changes - that way we're not trying to tackle both at once.
So, I could at least foresee that we might be trying to pull something together fully near the end of 2021, maybe early into next year, but this is also largely dependent on the React team's own timeline for React 18.
Requests for Help
As always, we welcome anyone who'd like to help contribute! The biggest immediate needs are:
React 18 alpha compat testing
We've already got an issue at #1732 asking people to try out React-Redux v7 with the React 18 alphas, and try to come up with actual examples of bugs and places where things break. That would give us things to try testing against as we work on Concurrent compat.
Related to this, Daishi Kato has put together a testbed that checks whether libraries potentially get along with Concurrent rendering, at https://github.com/dai-shi/will-this-react-global-state-work-in-concurrent-rendering . That will likely be a useful starting point.
If folks really want to dig in, I know that there's been a couple experiments with trying to modify React-Redux to use
useMutableSource
already, and it would be interesting to see some PRs to get an idea of how much code churn that involves.We're also going to want to freshen up the https://github.com/reduxjs/react-redux-benchmarks repo so that we can do perf benchmarks on new versions.
Finally, both the benchmarks repo and our tests will need updating to actually use React 18's new APIs, and we'll need new test scenarios that leverage those to have meaningful behavior checks.
TypeScript Conversion
Per #1737 , we've got the first couple steps going on porting the codebase to TS (just some first build tweaks so far). We'd love to have more folks get involved here, especially since we maintainers don't have time to seriously work on that part right now.
The text was updated successfully, but these errors were encountered: