-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
refactor: introduce redux toolkit #23460
refactor: introduce redux toolkit #23460
Conversation
f6259d3
to
8ab23ed
Compare
Codecov Report
@@ Coverage Diff @@
## master #23460 +/- ##
=======================================
Coverage 67.72% 67.72%
=======================================
Files 1916 1917 +1
Lines 74033 74053 +20
Branches 8040 8045 +5
=======================================
+ Hits 50137 50156 +19
- Misses 21848 21850 +2
+ Partials 2048 2047 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Thank you so much @justinpark for this PR! I'm tagging some folks here to help with testing and also for awareness given that Redux Toolkit improves the way to access the store and can really help with new features. |
Love it! Introducing redux toolkit was loooong overdue |
For those reviewing the PR, keep in mind that getDefaultMiddleware includes the immutabilityMiddleware and serializabilityMiddleware by default in development environments (it does not include them in production). This will produce warnings and errors such as: These errors are expected, and a great addition to our quality checks, and we should work to resolve them incrementally. |
@justinpark The immutability middleware is finding problems in many places. Screen.Recording.2023-03-24.at.16.23.53.movI see two possible solutions:
|
@michael-s-molina thanks for the detail testing and catching the side effects. In order to properly use redux-toolkit going forward, I believe it is more appropriate to first address the current errors rather than excluding additional middleware (immutability, serializability). This is because future planned features, such as rdk query, may be dependent on such middlewares. This has raised questions about whether it is the right direction to use the redux-toolkit query before proceeding with bug fixes. The redux toolkit, which is being introduced to simplify the redux structure, seems to be causing more complex dependency issues like this. |
No problem. I can help you test and identify the errors, and submit fixes. Let's keep this PR open and address the issues first then.
@justinpark RTK is actually pointing out bugs that currently exist in our Redux use but are not noticed. I really like the fact that now we can see these errors and actually fix them. This will improve quality.
Even if the complexity is a little higher, I would vote for library consistency here. Over the years we had a proliferation of libraries that many times offered the same functionality or were not consistent with each other. That resulted in many migrations over the years and wasted resources. I think it's an acceptable trade off. |
@justinpark I started submitting PRs to fix state mutations and help us merge this PR. I'm referencing this PR when submitting the fixes so you can follow along. |
b0177be
to
8f7a421
Compare
Got your point. Okay I'll go ahead of the rtk query migration. |
8f7a421
to
197bd34
Compare
@michael-s-molina I rebase the branch including #23522 |
@justinpark The errors fixed on iteration 1 were resolved. Iteration 2 is currently waiting for reviews. |
@michael-s-molina Since we changed the violation notice of immutability and serializability from error to warn, your iterations won't be a hard blocker. |
@justinpark |
Got it. Thanks for confirm. Will wait until all iterations are completed |
a5ff247
to
5193ecb
Compare
rebased master including iteration 2 (#23535) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Seems cleaner and safer already :D
Slapping a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
SUMMARY
Following up the discussion of #23257,
this commit introduces the redux-toolkit as a prerequisite for rdk(redux toolkit) query.
In order to consolidate the multiple state management solution, superset team decided to leverage the redux with toolkit in order to organize the existing redux state.
Redux toolkit also includes the rdk query package which can replace the existing react-query hooks (which is a similar solution to minimize the state of async api request) with a single solution.
This commit also use the configureStore method of the @reduxjs/toolkit package, which replaces createStore since Redux Toolkit is our (redux official channel) recommended approach for writing Redux logic today, including store setup, reducers, data fetching, and more.
After this commit merged, we can replace existing react-query by rdk-query too.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TESTING INSTRUCTIONS
N/A
ADDITIONAL INFORMATION
cc: @michael-s-molina @ktmud