-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
fix(sqllab): avoid unexpected re-rendering on DatabaseSelector #21316
fix(sqllab): avoid unexpected re-rendering on DatabaseSelector #21316
Conversation
Codecov Report
@@ Coverage Diff @@
## master #21316 +/- ##
=======================================
Coverage 66.66% 66.66%
=======================================
Files 1794 1794
Lines 68639 68643 +4
Branches 7300 7301 +1
=======================================
+ Hits 45755 45764 +9
+ Misses 21014 21011 -3
+ Partials 1870 1868 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Thanks for the PR @justinpark. Is there a reason for removing AsyncSelect
useEffect
dependencies?
b777a0d
to
243ba07
Compare
@michael-s-molina Because fetchPage kept changing while initializing due to the object dependencies, useEffect has been triggered multiple times which causes unnecessary I made a change to reduce and fix the dependencies for fetchPage and rollback this useEffect dependencies. |
@justinpark We can't add the responsibility of the immutability of the |
6685af6
to
b5242ea
Compare
Okay. @michael-s-molina I finally cleaned up the main cause.
superset/superset-frontend/src/components/Select/AsyncSelect.tsx Lines 196 to 200 in 8c16806
superset/superset-frontend/src/components/Select/AsyncSelect.tsx Lines 214 to 223 in 8c16806
superset/superset-frontend/src/components/Select/AsyncSelect.tsx Lines 302 to 319 in 8c16806
superset/superset-frontend/src/components/Select/AsyncSelect.tsx Lines 356 to 364 in 8c16806
superset/superset-frontend/src/components/Select/AsyncSelect.tsx Lines 487 to 496 in 8c16806
superset/superset-frontend/src/components/DatabaseSelector/index.tsx Lines 135 to 144 in b739e27
superset/superset-frontend/src/components/Select/AsyncSelect.tsx Lines 473 to 477 in b739e27
superset/superset-frontend/src/components/Select/AsyncSelect.tsx Lines 513 to 517 in b739e27
|
f4c2282
to
2b1abdc
Compare
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. Thanks for the fixes @justinpark!
SUMMARY
Reopen: #21141
Since DatabaseSelector component has an unnecessary key, DatabaseSelector will be re-mounted rather than update whenever currentDatabase object is updated. This causes the unexpected duplicate database list api request.
This commit removes this key so will skip unnecessary re-rendering and data fetching.
It also fixes the logic for currentDb that directly transform from db instead of useState. (This resolves the issue for #21174)
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before:
After:
TESTING INSTRUCTIONS
go to Sql Editor and check the network list
ADDITIONAL INFORMATION
cc: @ktmud