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

Factor out an inner version of DetailsList which uses hooks #12870

Merged
merged 2 commits into from
Sep 4, 2020

Conversation

ThomasMichon
Copy link
Member

@ThomasMichon ThomasMichon commented Apr 24, 2020

Started the conversion process of DetailsList to use React Hooks, which will provide a better platform for optimizing DetailsList and its excessive re-render issues.

For the moment, a DetailsListInner component consumes the Props and State from DetailsList, along with any internal callbacks and overridden props uses to manage the component instance.
This preserves the complete behavior and caller compatibility of DetailsList, while providing initial optimization using React.useCallback and React.useMemo for event handlers and other render props.

Fixes #14292

Microsoft Reviewers: Open in CodeFlow

@size-auditor
Copy link

size-auditor bot commented Apr 24, 2020

Asset size changes

Project Bundle Baseline Size New Size Difference
office-ui-fabric-react fluentui-react-next-DetailsList 213.959 kB 213.872 kB BelowBaseline     -87 bytes
office-ui-fabric-react office-ui-fabric-react-DetailsList 213.959 kB 213.872 kB BelowBaseline     -87 bytes
office-ui-fabric-react office-ui-fabric-react-ShimmeredDetailsList 224.554 kB 224.456 kB BelowBaseline     -98 bytes
office-ui-fabric-react fluentui-react-next-ShimmeredDetailsList 224.554 kB 224.456 kB BelowBaseline     -98 bytes

ExceedsTolerance Over Tolerance (1024 B) ExceedsBaseline Over Baseline BelowBaseline Below Baseline New New Deleted  Removed 1 kB = 1000 B

Baseline commit: 234afcd191b0555f88c90c874dc341f8e1cf9666 (build)

@msft-github-bot
Copy link
Contributor

msft-github-bot commented Apr 24, 2020

Perf Analysis

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
BaseButton mount 882 895 5000
ButtonNext mount 629 620 5000
Checkbox mount 1580 1650 5000
CheckboxBase mount 1311 1321 5000
CheckboxNext mount 1709 1707 5000
ChoiceGroup mount 5146 5022 5000
ChoiceGroupNext mount 5272 4988 5000
ComboBox mount 929 908 1000
CommandBar mount 8055 8103 1000
ContextualMenu mount 16979 16634 1000
DefaultButton mount 1117 1181 5000
DetailsRow mount 3699 3682 5000
DetailsRowFast mount 3715 3744 5000
DetailsRowNoStyles mount 3469 3582 5000
Dialog mount 1529 1526 1000
DocumentCardTitle mount 1922 1915 1000
Dropdown mount 2631 2724 5000
FocusZone mount 1894 1913 5000
IconButton mount 1755 1853 5000
Label mount 354 352 5000
Link mount 479 465 5000
LinkNext mount 465 464 5000
MenuButton mount 1489 1407 5000
MessageBar mount 2144 2201 5000
MessageBarNext mount 2164 2205 5000
Nav mount 3315 3261 1000
OverflowSet mount 1471 1496 5000
OverflowSetNext mount 1069 1066 5000
Panel mount 1523 1482 1000
Persona mount 862 887 1000
Pivot mount 1428 1460 1000
PivotNext mount 1441 1467 1000
PrimaryButton mount 1306 1266 5000
SearchBox mount 1382 1395 5000
SearchBoxNext mount 1378 1375 5000
Shimmer mount 2755 2700 5000
ShimmerNext mount 2596 2587 5000
Slider mount 1523 1550 5000
SliderNext mount 2027 1978 5000
SpinButton mount 5591 5356 5000
SpinButtonNext mount 5366 5374 5000
Spinner mount 440 479 5000
SplitButton mount 3232 3208 5000
Stack mount 541 529 5000
StackWithIntrinsicChildren mount 2036 1981 5000
StackWithTextChildren mount 5107 5043 5000
SwatchColorPicker mount 10364 10483 5000
SwatchColorPickerNext mount 10447 10402 5000
TagPicker mount 2793 2790 5000
TeachingBubble mount 52643 52676 5000
TeachingBubbleNext mount 52428 53696 5000
Text mount 411 456 5000
TextField mount 1408 1382 5000
ThemeProvider mount 4305 4353 5000
ThemeProvider virtual-rerender 451 452 5000
Toggle mount 829 859 5000
ToggleNext mount 870 823 5000
button mount 120 120 5000

Perf Analysis (Fluent)

⚠️ 4 potential perf regressions detected

Potential regressions comparing to master

Scenario Current PR Ticks Baseline Ticks Ratio Regression Analysis
ButtonOverridesMissPerf.default 1825 49 37.24:1 analysis
ButtonUseCssNestingPerf.default 1153 53 21.75:1 analysis
ButtonUseCssPerf.default 856 48 17.83:1 analysis
ChatWithPopoverPerf.default 492 483 1.02:1 analysis
Perf comparison
Status Scenario Fluent TPI Fabric TPI Ratio Iterations Ticks
🎯 Avatar.Fluent 0.45 0.49 0.92:1 2000 898
🦄 Button.Fluent 0.12 0.19 0.63:1 5000 604
🔧 Checkbox.Fluent 0.7 0.36 1.94:1 1000 698
🎯 Dialog.Fluent 0.17 0.23 0.74:1 5000 834
🔧 Dropdown.Fluent 3.12 0.52 6:1 1000 3115
🔧 Icon.Fluent 0.15 0.06 2.5:1 5000 771
🦄 Image.Fluent 0.09 0.13 0.69:1 5000 445
🔧 Slider.Fluent 1.72 0.37 4.65:1 1000 1718
🔧 Text.Fluent 0.07 0.04 1.75:1 5000 372
🦄 Tooltip.Fluent 0.12 20.78 0.01:1 5000 598

🔧 Needs work     🎯 On target     🦄 Amazing

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
PortalMinimalPerf.default 176 117 1.5:1
GridMinimalPerf.default 444 333 1.33:1
TableMinimalPerf.default 485 375 1.29:1
Image.Fluent 445 356 1.25:1
RefMinimalPerf.default 260 210 1.24:1
AttachmentMinimalPerf.default 185 151 1.23:1
SkeletonMinimalPerf.default 462 378 1.22:1
BoxMinimalPerf.default 411 347 1.18:1
LabelMinimalPerf.default 461 392 1.18:1
Tooltip.Fluent 598 508 1.18:1
LayoutMinimalPerf.default 447 381 1.17:1
ReactionMinimalPerf.default 439 376 1.17:1
StatusMinimalPerf.default 789 673 1.17:1
DividerMinimalPerf.default 406 353 1.15:1
FormMinimalPerf.default 446 387 1.15:1
Button.Fluent 604 523 1.15:1
ChatDuplicateMessagesPerf.default 465 407 1.14:1
ChatMinimalPerf.default 679 601 1.13:1
FlexMinimalPerf.default 324 286 1.13:1
TextMinimalPerf.default 383 339 1.13:1
Text.Fluent 372 332 1.12:1
ButtonMinimalPerf.default 186 168 1.11:1
DialogMinimalPerf.default 844 763 1.11:1
SegmentMinimalPerf.default 387 348 1.11:1
CardMinimalPerf.default 623 565 1.1:1
ListMinimalPerf.default 516 469 1.1:1
PopupMinimalPerf.default 757 689 1.1:1
TextAreaMinimalPerf.default 517 472 1.1:1
ImageMinimalPerf.default 415 382 1.09:1
AccordionMinimalPerf.default 157 146 1.08:1
MenuMinimalPerf.default 902 837 1.08:1
Checkbox.Fluent 698 646 1.08:1
Icon.Fluent 771 712 1.08:1
AnimationMinimalPerf.default 423 395 1.07:1
HeaderMinimalPerf.default 420 391 1.07:1
ProviderMergeThemesPerf.default 2113 1968 1.07:1
ProviderMinimalPerf.default 1031 965 1.07:1
TreeMinimalPerf.default 935 870 1.07:1
DropdownManyItemsPerf.default 814 767 1.06:1
CheckboxMinimalPerf.default 3016 2865 1.05:1
ToolbarMinimalPerf.default 1001 950 1.05:1
EmbedMinimalPerf.default 2005 1931 1.04:1
HeaderSlotsPerf.default 826 791 1.04:1
ItemLayoutMinimalPerf.default 1298 1245 1.04:1
RadioGroupMinimalPerf.default 468 451 1.04:1
TooltipMinimalPerf.default 824 789 1.04:1
VideoMinimalPerf.default 660 635 1.04:1
Avatar.Fluent 898 862 1.04:1
Dialog.Fluent 834 804 1.04:1
CarouselMinimalPerf.default 474 461 1.03:1
InputMinimalPerf.default 1397 1361 1.03:1
AlertMinimalPerf.default 304 298 1.02:1
AttachmentSlotsPerf.default 1160 1140 1.02:1
LoaderMinimalPerf.default 796 782 1.02:1
IconMinimalPerf.default 701 689 1.02:1
Slider.Fluent 1718 1683 1.02:1
DropdownMinimalPerf.default 3121 3075 1.01:1
MenuButtonMinimalPerf.default 1640 1628 1.01:1
TableManyItemsPerf.default 2288 2262 1.01:1
CustomToolbarPrototype.default 4030 3975 1.01:1
Dropdown.Fluent 3115 3096 1.01:1
SliderMinimalPerf.default 1659 1652 1:1
SplitButtonMinimalPerf.default 3900 3897 1:1
TreeWith60ListItems.default 231 236 0.98:1
ButtonSlotsPerf.default 620 646 0.96:1
AvatarMinimalPerf.default 487 521 0.93:1
ListWith60ListItems.default 974 1129 0.86:1
ListCommonPerf.default 734 964 0.76:1
ListNestedPerf.default 625 893 0.7:1

@msft-github-bot
Copy link
Contributor

@joschect

Gentle ping that this issue needs attention.

@JustSlone
Copy link
Collaborator

@dzearing and @KevinTCoughlin can you take a look at this PR?

@ecraig12345
Copy link
Member

Very belatedly circling back on this--one of our major goals for version 8 is strict mode compliance, and the UNSAFE_ methods in DetailsList are one of the blockers (see #14292). We were leaning towards getting rid of the unsafe methods without conversion to a function component, but David reminded me that this PR existed.

@ThomasMichon Would you have time to finish this in the next 6 weeks or so, or will someone else (likely @MLoughry or I) need to help? I also wonder if it should be re-targeted to react-next to reduce regression risk within v7.

@dzearing
Copy link
Member

There are a number of errors:

R!   100:10  error  Function name `DetailsListInner` must match one of the following formats: camelCase                                                                                                                 @typescript-eslint/naming-convention
ERR!   231:6   error  React Hook React.useMemo has missing dependencies: 'defaultOnRenderDetailsFooter' and 'props.onRenderDetailsFooter'. Either include them or remove the dependency array                             react-hooks/exhaustive-deps
ERR!   282:5   error  React Hook React.useCallback has missing dependencies: 'columnReorderOptions' and 'rootRef'. Either include them or remove the dependency array                                                     react-hooks/exhaustive-deps
ERR!   282:6   error  React Hook React.useCallback has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked                                                    react-hooks/exhaustive-deps
ERR!   327:6   error  React Hook React.useMemo has a missing dependency: 'groupProps'. Either include it or remove the dependency array                                                                                   react-hooks/exhaustive-deps
ERR!   328:5   error  React Hook React.useMemo has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked                                                        react-hooks/exhaustive-deps
ERR!   360:6   error  React Hook React.useMemo has a missing dependency: 'groupProps'. Either include it or remove the dependency array                                                                                   react-hooks/exhaustive-deps
ERR!   361:5   error  React Hook React.useMemo has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked                                                        react-hooks/exhaustive-deps
ERR!   441:5   error  React Hook React.useCallback has missing dependencies: 'defaultOnRenderRow', 'onRenderMissingItem', 'props.onRenderRow', and 'sumColumnWidths'. Either include them or remove the dependency array  react-hooks/exhaustive-deps
ERR!   543:5   error  React Hook React.useCallback has a missing dependency: 'focusZoneRef'. Either include it or remove the dependency array                                                                             react-hooks/exhaustive-deps
ERR!   553:6   error  React Hook React.useCallback has a missing dependency: 'headerRef'. Either include it or remove the dependency array                                                                                react-hooks/exhaustive-deps

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 21, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit b7c4f55:

Sandbox Source
Fluent UI Button Configuration
microsoft/fluentui: codesandbox-react-template Configuration
microsoft/fluentui: codesandbox-react-next-template Configuration
microsoft/fluentui: codesandbox-react-northstar-template Configuration

@joschect
Copy link
Contributor

Looks like they're only lint errors, the stuff on the page seems to be working correctly.

@ecraig12345
Copy link
Member

ecraig12345 commented Aug 21, 2020

For the react-hooks lint rules, it's best if you can get rid of the warning without disabling the rule, such as by fixing any real issues (definitely always take time to at least consider whether the "missing" dependencies listed could be capturing a stale mutable value), adding useCallback etc, or adding dependencies even if you know they will never change. That helps ensure future modifications to the code are also validated.

If the omission is intentional, disabling the rule is fine (preferably with a comment explaining why). ESLint syntax for inline comments on disables is // eslint-disable rule-name-here -- reason for disabling.

@joschect
Copy link
Contributor

As far as I can tell this is ready to go in whenever the lint has been fixed. I'm approving!

@JustSlone
Copy link
Collaborator

@dzearing @joschect @paulgildea before we merge this we should send the FYI to partners (via e-mail or teams). I don't think we need to wait a long time, just so they know a build soon will have the change (we should probably reply with the actual build when it's released).

Also, I assume @ThomasMichon can help with making sure SharePoint is aware of the change it integrates well, since they will pick up releases the fastest.

@joschect
Copy link
Contributor

Triggering new build

@joschect
Copy link
Contributor

joschect commented Sep 4, 2020

Closing and reopening a final time before push

@joschect joschect closed this Sep 4, 2020
@joschect joschect reopened this Sep 4, 2020
@joschect joschect merged commit 231236f into microsoft:master Sep 4, 2020
@msft-github-bot
Copy link
Contributor

🎉office-ui-fabric-react@v7.134.3 has been released which incorporates this pull request.:tada:

Handy links:

hutchcodes pushed a commit to hutchcodes/fluentui that referenced this pull request Sep 10, 2020
…t#12870)

* Factor out hook-based inner logic from DetailsList

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

Successfully merging this pull request may close these issues.

DetailsList: strict mode compliance (UNSAFE_, hard)
6 participants