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(deps): update to React 18 #526

Closed
wants to merge 10 commits into from
Closed

Conversation

maxcao13
Copy link
Member

@maxcao13 maxcao13 commented Sep 29, 2022

Fixes #482
Depends on patternfly/patternfly-react#7142

What's been updated:

"react": "^17.0.2" => "^18.2.0",
"react-dom": "^17.0.2" => "react-dom": "^18.2.0",

@testing-library/dom: 8.11.3 => 8.18.1
@testing-library/jest-dom: 5.16.2 => 5.16.5
@testing-library/react: 12.1.4 => 13.4.0
@testing-library/user-event: 13.5.0 => 14.4.3

What's been added:

"@types/react": "^18.0.21", // typescript react types
"@types/react-dom": "^18.0.6",

"react-test-renderer": "^18.2.0",

Noteworthy: the update of @testing-library/user-event has made all their api calls to return promises, await and async should be used for those calls in our tests now. https://github.com/testing-library/user-event/releases/tag/v14.0.0

@maxcao13 maxcao13 added dependencies Pull requests that update a dependency file build labels Sep 29, 2022
@maxcao13 maxcao13 changed the title build(deps): update to React 18 chore(deps): update to React 18 Sep 29, 2022
@andrewazores andrewazores added the chore Refactor, rename, cleanup, etc. label Sep 29, 2022
@andrewazores
Copy link
Member

andrewazores commented Sep 29, 2022

yarn format:apply should fix the CI failure, or at least let it advance to the next step.

Or npm run format:apply if you don' have yarn on your PATH.

@maxcao13
Copy link
Member Author

maxcao13 commented Sep 29, 2022

Should es-lint formatting be applied too? I noticed it's not included in the format command.

@maxcao13 maxcao13 requested review from andrewazores and tthvo and removed request for andrewazores September 29, 2022 21:53
@maxcao13 maxcao13 marked this pull request as ready for review September 29, 2022 22:12
@andrewazores
Copy link
Member

Should es-lint formatting be applied too? I noticed it's not included in the format command.

The last time I tried it, which was quite a while ago, the auto-formatting it applied actually broke things and needed manual cleanup by hand, and it was quite a significant amount of busywork. I just tried it again now and it looks like it applies some safe fixes fine, though there are many other linting warnings still present after.

I think you can update the format:apply script to also run eslint:apply since it seems safe. Don't add eslint:check to format:check yet because there will still be a bunch of lint warnings emitted right now, and adding it to that script would cause builds to fail until we clean up the lint issues.

preloadState: preloadedState,
history: history,
it('removes a recording after receiving a notification', async () => {
await act(async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Some reasons behind wrapping these calls in act?

Copy link
Member Author

Choose a reason for hiding this comment

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

There was a lot of console warnings with the tests before adding that, but other than that not actually sure of the underlying reason why that fixes it.

Copy link
Member

Choose a reason for hiding this comment

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

Pretty odd! This only happens with *RecordingsTable components :D

Copy link
Member

Choose a reason for hiding this comment

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

Seems like using iframe for ReportView causes this issue. It uses onLoad callback that updates React states outside React callstack, which throws a warning in tests. Surprisingly, this didn't get caught in old versions of React testing.

<iframe title="Automated Analysis" srcDoc={report} {...rest} onLoad={onLoad} hidden={!(loaded && isExpanded)} />

@maxcao13
Copy link
Member Author

maxcao13 commented Sep 30, 2022

There are some rendering problems when actually running the web-client with React 18, it just seems a lot more clunky and slower to use. Currently investigating the reason.

@maxcao13
Copy link
Member Author

maxcao13 commented Sep 30, 2022

There are some rendering problems when actually running the web-client with React 18, it just seems a lot more clunky and slower to use. Currently investigating the reason.

After a lot of digging and testing, I'm unable to pinpoint the root of the problems and there doesn't seem to be many problems from users online with React 18 in general with what is going on here - Thuan's PR does seems to speed up rendering but the main problem is that intermediate and default states seems to flicker in between rendering. The most obvious replication of this is if you click on the Recordings tab with an Active Recording and click to a different tab and keep clicking back and forth. There are hacks that can be used to solve these problems, but obviously this seems to be part of a bigger issue.

So I'm beginning to wonder if it is a Patternfly issue or not since they do not fully support React 18 yet, and won't do so until their next release in early 2023. patternfly/patternfly-react#7142 (comment). If so, this should be put off until then, but for now it's unclear. Updating to React 18 isn't a priority in anyway either.

@github-actions
Copy link

github-actions bot commented Dec 13, 2022

This PR/issue depends on:

@andrewazores
Copy link
Member

This PR/issue depends on:

Not actually resolved, just autoclosed due to inactivity.

@maxcao13
Copy link
Member Author

Patternfly 5 has been released with full support of React 18 https://medium.com/patternfly/patternflys-major-release-everything-you-need-to-know-62f7c890ff57

Here's a full upgrade article: https://www.patternfly.org/get-started/upgrade/

@maxcao13 maxcao13 closed this Aug 21, 2023
@maxcao13
Copy link
Member Author

Probably be better to start from scratch here.

@maxcao13 maxcao13 deleted the react-18 branch August 21, 2023 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked build chore Refactor, rename, cleanup, etc. dependencies Pull requests that update a dependency file dependent safe-to-test
Projects
No open projects
Status: Stretch Goals
Status: Pushed to 2.4.0
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

[Task] Update to React 18
3 participants