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

chore: Upgrade to React 18 #1636

Merged
merged 16 commits into from
Jun 27, 2022
Merged

chore: Upgrade to React 18 #1636

merged 16 commits into from
Jun 27, 2022

Conversation

RayRedGoose
Copy link
Contributor

@RayRedGoose RayRedGoose commented Jun 14, 2022

Summary

  • Upgrade react and react-dom to v18
  • Upgrade @types/react and @types/react-dom to v18
  • Update component types to remove deprecated types and fix issues with children in types
  • Update testing library to support React 18

Resolved: #1527

dependencies

Checklist

  • tests are changed or added
  • code has been documented
  • design approved final implementation
  • a11y approved final implementation
  • code adheres to the API & Pattern guidelines

@cypress
Copy link

cypress bot commented Jun 14, 2022



Test summary

699 0 2 0Flakiness 0


Run details

Project canvas-kit
Status Passed
Commit 27dca24 ℹ️
Started Jun 27, 2022 10:59 PM
Ended Jun 27, 2022 11:04 PM
Duration 04:40 💡
OS Linux Ubuntu - 20.04
Browser Electron 94

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@RayRedGoose RayRedGoose self-assigned this Jun 15, 2022
@RayRedGoose RayRedGoose added dependencies Pull requests that update a dependency file 8.x ready for review Code is ready for review labels Jun 15, 2022
@RayRedGoose RayRedGoose linked an issue Jun 16, 2022 that may be closed by this pull request
@RayRedGoose RayRedGoose marked this pull request as ready for review June 16, 2022 15:17
return (
<Flex
as={Element}
Copy link
Member

Choose a reason for hiding this comment

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

Kind of a sneaky change to a real polymorphic component.

export interface ActionBarListProps<T = unknown>
extends Partial<ExtractProps<typeof HStack, never>> {
export interface ActionBarListProps<T = any>
extends Omit<Partial<ExtractProps<typeof HStack, never>>, 'children'> {
Copy link
Member

Choose a reason for hiding this comment

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

Why is omitting children necessary now and not before? HStack always had children as part of the interface. Wouldn't that clash before?

@@ -30,7 +30,7 @@ export interface ActionBarListProps<T = unknown>
* {(item) => <ActionBar.Item key={item.id} name={item.name}>{item.text}</ActionBar.Item>}
* </ActionBar.List>
*/
children: ((item: T) => React.ReactNode) | React.ReactNode;
children: ((item: T, index: number) => React.ReactNode) | React.ReactNode;
Copy link
Member

Choose a reason for hiding this comment

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

Good catch

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this shouldn't use ListBoxProps instead.

@@ -84,15 +84,15 @@ describe('Popper', () => {

// force PopperJS to run
// eslint-disable-next-line compat/compat
await act(() => new Promise(requestAnimationFrame));
await act(() => new Promise<any>(requestAnimationFrame));
Copy link
Member

Choose a reason for hiding this comment

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

Why is this any needed? It should extract the type from requestAnimationFrame, but we don't actually care about the return type.

Copy link
Member

Choose a reason for hiding this comment

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

ReactDOM test utils changed the type of the promise that could be returned to act and forced it to be void even though the promise return type is ignored. requestAnimationFrame takes a callback that expects a number and they 2 come into conflict.

The alternative is:

await act(() => new Promise(cb => requestAnimationFrame(() => cb())));

But that seems messier

@@ -17,7 +17,8 @@ import {
import {useTabsModel} from './useTabsModel';

// Use `Partial` here to make `spacing` optional
export interface TabListProps<T = unknown> extends Partial<ExtractProps<typeof Stack, never>> {
export interface TabListProps<T = any>
extends Omit<Partial<ExtractProps<typeof Stack, never>>, 'children'> {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if ExtractProps should remove children... It is easier to add children than to take it away. I don't like using Omit as the type becomes much messier. All the Extract* utility types avoid using it and instead return clean interfaces

@NicholasBoll NicholasBoll added automerge and removed ready for review Code is ready for review labels Jun 27, 2022
@workday-canvas-kit workday-canvas-kit enabled auto-merge (squash) June 27, 2022 23:00
@workday-canvas-kit workday-canvas-kit merged commit 026b667 into Workday:prerelease/major Jun 27, 2022
@RayRedGoose RayRedGoose deleted the upgrade-to-react-18 branch June 28, 2022 16:58
@willklein
Copy link
Contributor

Note, I'm removing this text from the PR description as a correction.

BREAKING CHANGES

Canvas Kit will require teams to be on version ^18.x or at least ^17.0 for backwards compatibility. To use have all React 18 features would require teams to upgrade root API, otherwise they will be ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.x automerge dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

React 18 Upgrade
5 participants