-
Notifications
You must be signed in to change notification settings - Fork 23
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
WP-4924 Redraw only once when store triggers along with ancestor rerender #96
WP-4924 Redraw only once when store triggers along with ancestor rerender #96
Conversation
RavenNumber of Findings: 0 |
Codecov Report
@@ Coverage Diff @@
## master #96 +/- ##
==========================================
+ Coverage 96.77% 96.96% +0.19%
==========================================
Files 5 5
Lines 62 66 +4
==========================================
+ Hits 60 64 +4
Misses 2 2
Continue to review full report at Codecov.
|
@@ -39,6 +41,9 @@ class _RedrawScheduler implements Function { | |||
|
|||
(component as react.Component)?.setState({}, chainedCallbacks); | |||
}) | |||
..forEach((component, callbacks) { |
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.
I can't wrap my head around why you have to iterate again. Can you help me understand that?
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.
Sure thing. We want to unset this flag only after all of the batched redraws (and the redraws they cause by rerendering their descendants) have completed.
Otherwise, if we just unset the flag after a component redraw, it's possible that subsequent redraws in the batch will cause redrawing of that component again.
@jayudey-wf ready for you |
would one of you guys want to verify that this update is functioning as you expect? @kylemcmorrow-wf @johnbland-wf @brentschuele-wf @brandonrodgers-wf @robbielamb-wf |
I think it looks good. |
@kylemcmorrow-wf To clarify, did you just pull these changes in, or also the |
I pulled in both, I believe redraws due to store triggers are being handled correctly, the code looks good to go. I was just mentioning that I'm seeing some issues specifically on our stuff (we have a uiComponent that re-renders a bunch, and since we aren't checking shouldBatchRedraw inside of shouldComponentUpdate anymore, it causes that component to redraw when before it didn't). So something like what is defined in SOX-6634 might still be useful if we want our re-renders to be even more restrictive. |
Cool, thanks for the info! |
+10
|
QA +1
@Workiva/release-management-pp |
+1 from RM |
@kylemcmorrow-wf sounds like a PureComponent need. ;) |
Ultimate Problem
Flux components were rerendered excessively when nested inside each other and a store trigger caused rerendering of those nested components.
See reduced test case here.
Solution
Track whether components were already redrawn during the current redraw batch.
All consumers will need to do is make sure to call
super.componentDidUpdate
in overrides, and they'll get this fix.OverReact PR (
FluxUiComponent
) is available here: Workiva/over_react#103.Testing
Verify tests pass.
Areas of Regression
Flux component rerendering
FYA @Workiva/web-platform-pp @Workiva/ui-platform-pp
FYI: @kylemcmorrow-wf @johnbland-wf @brentschuele-wf @brandonrodgers-wf @robbielamb-wf