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

Update React to 16.14 #21769

Merged
merged 1 commit into from
Mar 7, 2022
Merged

Conversation

ecraig12345
Copy link
Member

@ecraig12345 ecraig12345 commented Feb 15, 2022

Current Behavior

We're not on the latest 16.x versions of React and related deps and types. This was causing some problems with the storybook upgrade PR (#21742), and although there are other possible workarounds for those issues, it's probably good to update to the latest 16.x versions anyway.

New Behavior

Dependency updates and hoisting

Update to latest 16.x versions of:

  • react 16.14.0
  • react-dom 16.14.0
  • @types/react 16.14.23
  • @types/react-dom 16.9.14
  • react-test-renderer 16.14.0
  • @types/react-test-renderer 16.9.5

To avoid mismatches or dupes, this also required updates of:

  • csstype to ^3.0.2 in northstar
  • scheduler: this is a dep of React and is used as a dep of react-context-selector and react-bindings. Per discussion with Shift I moved this to a peer dep and allowed versions corresponding to either React 16 or 17.

Where any of these packages are used as devDependencies, hoist them to the root.

I also went ahead and hoisted enzyme, @types/enzyme, enzyme-adapter-react-16, and @types/enzyme-adapter-react-16 since this PR is already modifying the whole world and those deps are usually right next to the React ones in devDependencies lists. (The pinned versions are the same versions that were already being installed by the ~ or ^.)

Other changes required by dependency updates

The typing and behavior updates in the latest React 16.x necessitated a few other changes:

  • Add UNSAFE_ prefix to remaining deprecated React lifecycles that didn't have it (e.g. componentWillReceiveProps) to address new warning
  • Update names of property types from csstype
  • Add /** @jsxRuntime classic */ to a few files that had /** @jsx withSlots */ but didn't specify a jsxRuntime (addressing a new compiler error or warning IIRC)
  • Add eslint-disables for newly-deprecated React.KeyboardEvent properties
  • Fix useTimeout tests to account for React internals calling setTimeout
  • Update BaseSelectedItem to reflect React.Attributes type updates

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 15, 2022

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 6d1bd27:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration

@fabricteam
Copy link
Collaborator

fabricteam commented Feb 15, 2022

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-accordion
Accordion (including children components)
72.822 kB
22.054 kB
73.035 kB
22.11 kB
213 B
56 B
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
172.3 kB
48.272 kB
172.513 kB
48.34 kB
213 B
68 B
react-menu
Menu (including children components)
103.763 kB
31.935 kB
103.976 kB
31.998 kB
213 B
63 B
react-menu
Menu (including selectable components)
106.118 kB
32.298 kB
106.331 kB
32.361 kB
213 B
63 B
react-popover
Popover
96.563 kB
29.49 kB
96.776 kB
29.553 kB
213 B
63 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-avatar
Avatar
44.982 kB
13.059 kB
react-badge
Badge
20.869 kB
6.549 kB
react-badge
CounterBadge
21.737 kB
6.843 kB
react-badge
PresenceBadge
21.866 kB
6.536 kB
react-button
Button
28.013 kB
8.059 kB
react-button
CompoundButton
33.336 kB
9.037 kB
react-button
MenuButton
29.763 kB
8.656 kB
react-button
SplitButton
36.235 kB
9.857 kB
react-button
ToggleButton
37.395 kB
8.68 kB
react-card
Card - All
53.205 kB
15.27 kB
react-card
Card
48.898 kB
14.083 kB
react-card
CardFooter
7.653 kB
3.246 kB
react-card
CardHeader
8.931 kB
3.689 kB
react-card
CardPreview
7.626 kB
3.272 kB
react-combobox
Combobox
6.813 kB
2.895 kB
react-components
react-components: FluentProvider & webLightTheme
32.526 kB
10.645 kB
react-divider
Divider
15.301 kB
5.532 kB
react-image
Image
10.105 kB
3.952 kB
react-input
Input
21.538 kB
7.134 kB
react-label
Label
8.341 kB
3.487 kB
react-link
Link
11.102 kB
4.504 kB
react-portal
Portal
6.267 kB
2.168 kB
react-positioning
usePopper
23.21 kB
8.084 kB
react-provider
FluentProvider
14.009 kB
5.25 kB
react-select
Select
7.754 kB
3.258 kB
react-slider
Slider
22.975 kB
7.769 kB
react-spinner
Spinner
6.811 kB
2.895 kB
react-switch
Switch
22.598 kB
7.642 kB
react-text
Text - Default
10.793 kB
4.23 kB
react-text
Text - Wrappers
14.107 kB
4.573 kB
react-theme
Single theme token import
69 B
89 B
react-theme
Teams: all themes
29.426 kB
6.551 kB
react-theme
Teams: Light theme
18.42 kB
5.27 kB
react-tooltip
Tooltip
42.76 kB
14.701 kB
react-utilities
SSRProvider
189 B
161 B
🤖 This report was generated against db520179cfa98c0451a2b74affc7ea15f9238ac0

@ecraig12345 ecraig12345 force-pushed the react-16.14-upgrade branch 2 times, most recently from 560420c to 348647f Compare February 16, 2022 00:27
@ecraig12345
Copy link
Member Author

@layershifter I noticed with this upgrade, I'm getting errors due to changes from csstype 2 to 3, and unfortunately the fixes might affect public APIs. It looks like griffel still uses csstype 2, so I'm guessing you hit this before? Do you have any thoughts on what to do?

@size-auditor
Copy link

size-auditor bot commented Feb 16, 2022

Asset size changes

Project Bundle Baseline Size New Size Difference
office-ui-fabric-react fluentui-react-northstar-List 100.857 kB 101.07 kB ExceedsBaseline     213 bytes
office-ui-fabric-react fluentui-react-northstar-Dropdown 211.543 kB 211.756 kB ExceedsBaseline     213 bytes
office-ui-fabric-react fluentui-react-northstar-SplitButton 192.832 kB 193.045 kB ExceedsBaseline     213 bytes
office-ui-fabric-react fluentui-react-northstar-MenuButton 176.564 kB 176.777 kB ExceedsBaseline     213 bytes
office-ui-fabric-react fluentui-react-northstar-Menu 141.545 kB 141.758 kB ExceedsBaseline     213 bytes
office-ui-fabric-react fluentui-react-northstar-Toolbar 189.045 kB 189.258 kB ExceedsBaseline     213 bytes
office-ui-fabric-react fluentui-react-northstar-Chat 165.885 kB 166.098 kB ExceedsBaseline     213 bytes
office-ui-fabric-react fluentui-react-Dialog 196.338 kB 196.344 kB ExceedsBaseline     6 bytes
office-ui-fabric-react fluentui-react-Modal 88.824 kB 88.83 kB ExceedsBaseline     6 bytes
office-ui-fabric-react fluentui-react-TimePicker 222.694 kB 222.657 kB BelowBaseline     -37 bytes

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

Baseline commit: db520179cfa98c0451a2b74affc7ea15f9238ac0 (build)

@fabricteam
Copy link
Collaborator

fabricteam commented Feb 16, 2022

Perf Analysis (@fluentui/react)

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 1410 1382 5000 Possible regression
BaseButton mount 1409 1482 5000 Possible regression
Breadcrumb mount 3359 3484 1000 Possible regression
ButtonNext mount 877 840 5000 Possible regression
Checkbox mount 2099 2058 5000 Possible regression
CheckboxBase mount 1835 1944 5000 Possible regression
ChoiceGroup mount 5937 5949 5000 Possible regression
ComboBox mount 1471 1455 1000 Possible regression
CommandBar mount 12280 12524 1000 Possible regression
ContextualMenu mount 24318 21756 1000 Possible regression
DefaultButton mount 1686 1674 5000 Possible regression
DetailsRow mount 4720 4790 5000 Possible regression
DetailsRowFast mount 4792 4780 5000 Possible regression
DetailsRowNoStyles mount 4550 4514 5000 Possible regression
Dialog mount 2852 2921 1000 Possible regression
DocumentCardTitle mount 509 476 1000 Possible regression
Dropdown mount 4198 4201 5000 Possible regression
FluentProviderNext mount 2430 2381 5000 Possible regression
FluentProviderWithTheme mount 446 437 10 Possible regression
FluentProviderWithTheme virtual-rerender 393 408 10 Possible regression
FluentProviderWithTheme virtual-rerender-with-unmount 498 491 10 Possible regression
FocusTrapZone mount 2337 2322 5000 Possible regression
FocusZone mount 2343 2406 5000 Possible regression
IconButton mount 2360 2434 5000 Possible regression
Label mount 681 704 5000 Possible regression
Layer mount 3783 3707 5000 Possible regression
Link mount 856 811 5000 Possible regression
MakeStyles mount 2157 2143 50000 Possible regression
MenuButton mount 2077 2117 5000 Possible regression
MessageBar mount 2450 2700 5000 Possible regression
Nav mount 4189 4211 1000 Possible regression
OverflowSet mount 1551 1542 5000 Possible regression
Panel mount 2776 2720 1000 Possible regression
Persona mount 1290 1319 1000 Possible regression
Pivot mount 1884 1967 1000 Possible regression
PrimaryButton mount 1873 1839 5000 Possible regression
Rating mount 9465 9480 5000 Possible regression
SearchBox mount 1869 1885 5000 Possible regression
Shimmer mount 3202 3315 5000 Possible regression
Slider mount 2540 2553 5000 Possible regression
SpinButton mount 6406 6125 5000 Possible regression
Spinner mount 793 741 5000 Possible regression
SplitButton mount 4060 4047 5000 Possible regression
Stack mount 908 939 5000 Possible regression
StackWithIntrinsicChildren mount 3207 3145 5000 Possible regression
StackWithTextChildren mount 6813 6713 5000 Possible regression
SwatchColorPicker mount 13812 13669 5000 Possible regression
TagPicker mount 3256 3267 5000 Possible regression
TeachingBubble mount 15125 123726 5000 Possible regression
Text mount 824 797 5000 Possible regression
TextField mount 1945 1938 5000 Possible regression
ThemeProvider mount 1665 1642 5000 Possible regression
ThemeProvider virtual-rerender 975 1062 5000 Possible regression
ThemeProvider virtual-rerender-with-unmount 2438 2429 5000 Possible regression
Toggle mount 1243 1227 5000 Possible regression
buttonNative mount 437 428 5000 Possible regression
All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 1410 1382 5000 Possible regression
BaseButton mount 1409 1482 5000 Possible regression
Breadcrumb mount 3359 3484 1000 Possible regression
ButtonNext mount 877 840 5000 Possible regression
Checkbox mount 2099 2058 5000 Possible regression
CheckboxBase mount 1835 1944 5000 Possible regression
ChoiceGroup mount 5937 5949 5000 Possible regression
ComboBox mount 1471 1455 1000 Possible regression
CommandBar mount 12280 12524 1000 Possible regression
ContextualMenu mount 24318 21756 1000 Possible regression
DefaultButton mount 1686 1674 5000 Possible regression
DetailsRow mount 4720 4790 5000 Possible regression
DetailsRowFast mount 4792 4780 5000 Possible regression
DetailsRowNoStyles mount 4550 4514 5000 Possible regression
Dialog mount 2852 2921 1000 Possible regression
DocumentCardTitle mount 509 476 1000 Possible regression
Dropdown mount 4198 4201 5000 Possible regression
FluentProviderNext mount 2430 2381 5000 Possible regression
FluentProviderWithTheme mount 446 437 10 Possible regression
FluentProviderWithTheme virtual-rerender 393 408 10 Possible regression
FluentProviderWithTheme virtual-rerender-with-unmount 498 491 10 Possible regression
FocusTrapZone mount 2337 2322 5000 Possible regression
FocusZone mount 2343 2406 5000 Possible regression
IconButton mount 2360 2434 5000 Possible regression
Label mount 681 704 5000 Possible regression
Layer mount 3783 3707 5000 Possible regression
Link mount 856 811 5000 Possible regression
MakeStyles mount 2157 2143 50000 Possible regression
MenuButton mount 2077 2117 5000 Possible regression
MessageBar mount 2450 2700 5000 Possible regression
Nav mount 4189 4211 1000 Possible regression
OverflowSet mount 1551 1542 5000 Possible regression
Panel mount 2776 2720 1000 Possible regression
Persona mount 1290 1319 1000 Possible regression
Pivot mount 1884 1967 1000 Possible regression
PrimaryButton mount 1873 1839 5000 Possible regression
Rating mount 9465 9480 5000 Possible regression
SearchBox mount 1869 1885 5000 Possible regression
Shimmer mount 3202 3315 5000 Possible regression
Slider mount 2540 2553 5000 Possible regression
SpinButton mount 6406 6125 5000 Possible regression
Spinner mount 793 741 5000 Possible regression
SplitButton mount 4060 4047 5000 Possible regression
Stack mount 908 939 5000 Possible regression
StackWithIntrinsicChildren mount 3207 3145 5000 Possible regression
StackWithTextChildren mount 6813 6713 5000 Possible regression
SwatchColorPicker mount 13812 13669 5000 Possible regression
TagPicker mount 3256 3267 5000 Possible regression
TeachingBubble mount 15125 123726 5000 Possible regression
Text mount 824 797 5000 Possible regression
TextField mount 1945 1938 5000 Possible regression
ThemeProvider mount 1665 1642 5000 Possible regression
ThemeProvider virtual-rerender 975 1062 5000 Possible regression
ThemeProvider virtual-rerender-with-unmount 2438 2429 5000 Possible regression
Toggle mount 1243 1227 5000 Possible regression
buttonNative mount 437 428 5000 Possible regression

@@ -59,7 +59,7 @@ export interface ISelectedItemProps<T> extends IPickerItemProps<T> {
}

export type BaseSelectedItem = {
key?: React.Key;
key?: React.Key | null;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to match an update to the type of React.Attributes to include null in the key

@layershifter
Copy link
Member

scheduler should be a peerDependency:
https://github.com/dai-shi/use-context-selector/blob/7ca35cf68d08ba930a8b91c129ab00d1798300b9/package.json#L88

Can you please update it for @fluentui/react-context-selector& @fluentui/react-bindings?

@layershifter
Copy link
Member

@layershifter I noticed with this upgrade, I'm getting errors due to changes from csstype 2 to 3, and unfortunately the fixes might affect public APIs. It looks like griffel still uses csstype 2, so I'm guessing you hit this before? Do you have any thoughts on what to do?

Griffel will use csstype@3, microsoft/griffel#31.
Currently I don't see real issues in this PR. Can you please reference a specific change?

@ecraig12345
Copy link
Member Author

scheduler should be a peerDependency: https://github.com/dai-shi/use-context-selector/blob/7ca35cf68d08ba930a8b91c129ab00d1798300b9/package.json#L88

Can you please update it for @fluentui/react-context-selector& @fluentui/react-bindings?

Sure, what should the version range be? react-dom 16.14 uses scheduler ^0.19.1, and 17 uses 0.20.

One question about adding as a peer dep--although in reality scheduler should be available any time react-dom is, wouldn't there be an "unmet peer dependency" warning if people don't explicitly install scheduler in their repo as well?

@ecraig12345
Copy link
Member Author

I noticed with this upgrade, I'm getting errors due to changes from csstype 2 to 3, and unfortunately the fixes might affect public APIs. It looks like griffel still uses csstype 2, so I'm guessing you hit this before? Do you have any thoughts on what to do?

Griffel will use csstype@3, microsoft/griffel#31. Currently I don't see real issues in this PR. Can you please reference a specific change?

csstype 3 renames things like FontWeightProperty to Property.FontWeight. The places I had to update were all in northstar (example). I don't know if griffel includes direct references to any of the named types.

@layershifter
Copy link
Member

csstype 3 renames things like FontWeightProperty to Property.FontWeight.

It's not used in Teams directly AFAIR, it should not be a big issue.

I don't know if griffel includes direct references to any of the named types.

We use some other types there, we will handle this during upgrade. But nothing from csstype is exported directly.

@ling1726 ling1726 closed this Feb 17, 2022
@ling1726 ling1726 reopened this Feb 17, 2022
@ecraig12345
Copy link
Member Author

ecraig12345 commented Mar 1, 2022

scheduler should be a peerDependency: https://github.com/dai-shi/use-context-selector/blob/7ca35cf68d08ba930a8b91c129ab00d1798300b9/package.json#L88
Can you please update it for @fluentui/react-context-selector& @fluentui/react-bindings?

Sure, what should the version range be? react-dom 16.14 uses scheduler ^0.19.1, and 17 uses 0.20.

One question about adding as a peer dep--although in reality scheduler should be available any time react-dom is, wouldn't there be an "unmet peer dependency" warning if people don't explicitly install scheduler in their repo as well?

@layershifter What do you think is the correct version of scheduler to specify? Or should we allow either (^0.19.0 || ^0.20.0)?

EDIT: I realized that for react-context-selector, since we allow React 16 or 17, it makes sense to also allow scheduler 0.19 or 0.20 to match. For react-bindings I just did 0.19 since that package still has only React 16 in peer deps.

@fabricteam
Copy link
Collaborator

fabricteam commented Mar 1, 2022

Perf Analysis (@fluentui/react-northstar)

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
AccordionMinimalPerf.default 162 148 1.09:1
MenuMinimalPerf.default 927 852 1.09:1
ChatMinimalPerf.default 790 739 1.07:1
AttachmentMinimalPerf.default 169 159 1.06:1
CardMinimalPerf.default 594 568 1.05:1
AlertMinimalPerf.default 281 271 1.04:1
CheckboxMinimalPerf.default 2827 2720 1.04:1
ToolbarMinimalPerf.default 962 929 1.04:1
ButtonOverridesMissPerf.default 1733 1687 1.03:1
ButtonSlotsPerf.default 555 540 1.03:1
EmbedMinimalPerf.default 4305 4164 1.03:1
ListMinimalPerf.default 534 519 1.03:1
ReactionMinimalPerf.default 401 391 1.03:1
IconMinimalPerf.default 630 614 1.03:1
VideoMinimalPerf.default 652 630 1.03:1
MenuButtonMinimalPerf.default 1721 1689 1.02:1
ProviderMinimalPerf.default 1141 1119 1.02:1
AttachmentSlotsPerf.default 1127 1119 1.01:1
CarouselMinimalPerf.default 472 467 1.01:1
ChatDuplicateMessagesPerf.default 306 304 1.01:1
HeaderMinimalPerf.default 380 376 1.01:1
ListNestedPerf.default 593 587 1.01:1
ListWith60ListItems.default 666 657 1.01:1
RadioGroupMinimalPerf.default 474 468 1.01:1
SkeletonMinimalPerf.default 365 363 1.01:1
SliderMinimalPerf.default 1708 1694 1.01:1
TableManyItemsPerf.default 1924 1898 1.01:1
TableMinimalPerf.default 413 409 1.01:1
TooltipMinimalPerf.default 1028 1016 1.01:1
TreeWith60ListItems.default 188 187 1.01:1
AnimationMinimalPerf.default 552 552 1:1
AvatarMinimalPerf.default 203 202 1:1
DropdownMinimalPerf.default 3060 3046 1:1
HeaderSlotsPerf.default 754 751 1:1
InputMinimalPerf.default 1340 1339 1:1
LoaderMinimalPerf.default 695 692 1:1
StatusMinimalPerf.default 689 690 1:1
TextMinimalPerf.default 355 354 1:1
CustomToolbarPrototype.default 4124 4116 1:1
DialogMinimalPerf.default 785 790 0.99:1
ItemLayoutMinimalPerf.default 1231 1238 0.99:1
ProviderMergeThemesPerf.default 1774 1798 0.99:1
SplitButtonMinimalPerf.default 4393 4429 0.99:1
ChatWithPopoverPerf.default 396 405 0.98:1
DatepickerMinimalPerf.default 5653 5788 0.98:1
ImageMinimalPerf.default 382 390 0.98:1
LayoutMinimalPerf.default 365 373 0.98:1
PopupMinimalPerf.default 645 655 0.98:1
RefMinimalPerf.default 245 250 0.98:1
DividerMinimalPerf.default 366 378 0.97:1
GridMinimalPerf.default 340 349 0.97:1
LabelMinimalPerf.default 384 394 0.97:1
RosterPerf.default 1168 1201 0.97:1
SegmentMinimalPerf.default 348 357 0.97:1
TreeMinimalPerf.default 815 844 0.97:1
DropdownManyItemsPerf.default 672 698 0.96:1
PortalMinimalPerf.default 171 178 0.96:1
ButtonMinimalPerf.default 175 184 0.95:1
BoxMinimalPerf.default 340 363 0.94:1
FormMinimalPerf.default 389 413 0.94:1
ListCommonPerf.default 613 650 0.94:1
TextAreaMinimalPerf.default 489 518 0.94:1
FlexMinimalPerf.default 297 332 0.89:1

@layershifter
Copy link
Member

@layershifter What do you think is the correct version of scheduler to specify? Or should we allow either (^0.19.0 || ^0.20.0)?

Sounds good 👍

@ecraig12345 ecraig12345 force-pushed the react-16.14-upgrade branch 4 times, most recently from c0c4b99 to b46ece9 Compare March 1, 2022 19:39
@andrefcdias andrefcdias requested a review from Hotell March 2, 2022 13:16
@ecraig12345
Copy link
Member Author

Build is green (at least until it gets merge conflicts from publishing), so @Hotell and/or @microsoft/cxe-prg and @microsoft/fluentui-react-build can you take another look?

Copy link
Contributor

@Hotell Hotell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#strengthAndHonor

@ecraig12345 ecraig12345 force-pushed the react-16.14-upgrade branch 2 times, most recently from 4e0f967 to 0153d1a Compare March 7, 2022 19:51
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.

9 participants