Skip to content
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

Merged
merged 3 commits into from
Aug 11, 2017

Conversation

greglittlefield-wf
Copy link
Contributor

@greglittlefield-wf greglittlefield-wf commented Aug 8, 2017

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

@aviary2-wf
Copy link

aviary2-wf commented Aug 8, 2017

Raven

Number of Findings: 0

@codecov-io
Copy link

Codecov Report

Merging #96 into master will increase coverage by 0.19%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
lib/src/mixins/batched_redraws.dart 100% <100%> (ø) ⬆️
lib/src/component_client.dart 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update da81b7a...4c7f4ad. Read the comment docs.

@@ -39,6 +41,9 @@ class _RedrawScheduler implements Function {

(component as react.Component)?.setState({}, chainedCallbacks);
})
..forEach((component, callbacks) {

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?

Copy link
Contributor Author

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.

@maxwellpeterson-wf
Copy link
Member

@jayudey-wf ready for you

@jayudey-wf
Copy link
Contributor

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

@kylemcmorrow-wf
Copy link
Contributor

@jayudey-wf

I think it looks good.
I ended up pulling those changes into graph_app and I'm seeing some extra renders (after removing the manual shouldBatchRedraw switching), but I think that might be unrelated specifically to batch redraw (so we might have to keep some of the manual switching).

@greglittlefield-wf
Copy link
Contributor Author

@kylemcmorrow-wf To clarify, did you just pull these changes in, or also the FluxUiComponent ones in the over_react PR Workiva/over_react#103?

@kylemcmorrow-wf
Copy link
Contributor

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.

@greglittlefield-wf
Copy link
Contributor Author

Cool, thanks for the info!

@rmconsole3-wf rmconsole3-wf changed the title Redraw only once when store triggers along with ancestor rerender WP-4924 Redraw only once when store triggers along with ancestor rerender Aug 11, 2017
@maxwellpeterson-wf
Copy link
Member

+10

  • Tests pass
  • Kyle tried it in graph_app with success

@maxwellpeterson-wf
Copy link
Member

QA +1

  • Dev +1's
  • Dev/QA +10 with detail of what was tested
  • Tests created/updated
  • All tests pass

@Workiva/release-management-pp

@rmconsole-wf
Copy link
Contributor

+1 from RM

@rmconsole-wf rmconsole-wf merged commit 83e05ae into Workiva:master Aug 11, 2017
@johnbland-wf
Copy link

@kylemcmorrow-wf sounds like a PureComponent need. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.