Skip to content

Upgrade frontend to React 18 #3353

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

Merged
merged 20 commits into from
Aug 22, 2022
Merged

Upgrade frontend to React 18 #3353

merged 20 commits into from
Aug 22, 2022

Conversation

ammario
Copy link
Member

@ammario ammario commented Aug 2, 2022

Closes #961

@ammario ammario requested a review from a team as a code owner August 2, 2022 07:00
@ammario ammario requested a review from presleyp August 2, 2022 07:23
@Kira-Pilot
Copy link
Member

@ammario thanks for doing this! We wanted to discuss some of the React 18 changes in FE Variety before merging up - there are some rendering differences between 17 and 18. Do you mind if we hold off until then? We can mark it as a draft for now.

@ammario
Copy link
Member Author

ammario commented Aug 2, 2022

@ammario thanks for doing this! We wanted to discuss some of the React 18 changes in FE Variety before merging up - there are some rendering differences between 17 and 18. Do you mind if we hold off until then? We can mark it as a draft for now.

How about I fix these rendering concerns right now?

@Kira-Pilot
Copy link
Member

How about I fix these rendering concerns right now?

Well, it's not so much fixing them (although there might be some of that) so much as it is understanding them. Here is the React article discussing the changes we are most curious about. Some questions I have (although I haven't finished reading this through) are:

  • how will this work when running tests locally, especially considering we often make use of Jest's toBeCalledTimes?
  • Are there workarounds? Should we be limiting use of useEffect (probably)? There's a whole issue thread here.

None of that necessarily needs to be addressed in this PR - I just think usually we give folks a chance to read through the change logs before upgrading.
Would you like to join our next FE variety? We all committed to discuss the reading then. It would be nice to hear your perspective considering you did the upgrade already!

@presleyp
Copy link
Contributor

presleyp commented Aug 3, 2022

Yeah we had decided to discuss this in FE V so I'd like to go ahead and do that. It's best to take tickets that have been groomed - this one was still in Enqueue because we were waiting on the discussion.

@ammario
Copy link
Member Author

ammario commented Aug 3, 2022

Ok. I'm happy to attend the next one. Please add me to the invite.

@ammario
Copy link
Member Author

ammario commented Aug 3, 2022

I intend on handling this end to end so it shouldn't add any work to your plates.

@Kira-Pilot
Copy link
Member

@presleyp can add you to the invite!

@socket-security
Copy link

socket-security bot commented Aug 15, 2022

Socket Security Report

Dependency issues detected. If you merge this pull request, you will not be alerted to the instances of these issues again.

📜 New install scripts detected

A dependency change in this PR is introducing new install scripts to your install step.

Package Script field Location
core-js@3.24.1 (upgraded) postinstall site/package.json via @storybook/addon-actions@6.5.9
core-js-pure@3.24.1 (upgraded) postinstall site/package.json via @pmmmwh/react-refresh-webpack-plugin@0.5.7
Socket.dev scan summary
Issue Status
Did you mean? ✅ no new possible package typos
Install scripts ⚠️ 2 new install scripts detected
Telemetry ✅ no new telemetry
Troll package ✅ no new troll packages
Malware ✅ no new malware
Native code ✅ no new native modules

Powered by socket.dev

<ErrorSummary
error={props.createWorkspaceErrors[CreateWorkspaceErrors.GET_TEMPLATES_ERROR]}
/>
) : (
<></>
Copy link
Member

Choose a reason for hiding this comment

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

Instead of rendering a fragment here if the condition isn't met, we should be able to do this:

       {!!props.createWorkspaceErrors[CreateWorkspaceErrors.GET_TEMPLATES_ERROR] && (
          <ErrorSummary
            error={props.createWorkspaceErrors[CreateWorkspaceErrors.GET_TEMPLATES_ERROR]}
          />
        )}

The error message you're encountering is TS's confusing way of telling you that it's not evaluating the condition as a boolean, so it needs you to explicitly cast it as such.

Copy link
Member Author

Choose a reason for hiding this comment

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

Gotcha. I thought the ternary was clearer, but the !! syntax makes sense too.

@Kira-Pilot
Copy link
Member

@ammario this is good to go when you're ready to merge up. The act warnings work has been captured in #3626.

@ammario
Copy link
Member Author

ammario commented Aug 22, 2022

Thank you @Kira-Pilot. You deserve the clout on the git history for this one.

@ammario ammario merged commit 2ee6acb into main Aug 22, 2022
@ammario ammario deleted the react-18 branch August 22, 2022 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade to React 18+
4 participants