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

feat: update react & react-dom to v17 #338

Merged
merged 9 commits into from
Jul 20, 2023

Conversation

BilalQamar95
Copy link
Contributor

@BilalQamar95 BilalQamar95 commented Jun 8, 2023

Ticket

Upgrade React JS to v17

Description

Updated react & react-dom to v17 along with testing-library/react & react-test-renderer to respective compatible versions

Breaking Change

Upgrading React from version 16 to 17. This release includes breaking changes(the new JSX transform, changes to event handling, and deprecations of certain APIs), necessitating a major version increment. Eventually using the new JSX factory would be great but this PR focuses on bumping react to v17 along with respective packages.

Merge checklist:

  • Evaluate how your changes will impact existing consumers (e.g., frontend-app-learner-portal-enterprise, frontend-app-admin-portal, and frontend-app-enterprise-public-catalog). Will consumers safely be able to upgrade to this change without any breaking changes?
  • Ensure your commit message follows the semantic-release conventional commit message format. If your changes include a breaking change, ensure your commit message is explicitly marked as a BREAKING CHANGE so the NPM package is released as such.
  • Once CI is passing, verify the package versions that Lerna will increment to in the Github Action CI workflow logs.
    • Note: This may be found in the "Preview Updated Versions (dry run)" step in the Github Action CI workflow logs.

Post merge:

  • Verify Lerna created a release commit (e.g., chore(release): publish) that incremented versions in relevant package.json and CHANGELOG files, and created Git tags for those versions.
  • Run the Publish from package.json Github Action workflow to publish these new package versions to NPM.
    • This may be triggered by clicking the "Run workflow" option for the master branch.
  • Verify the new package versions were published to NPM (i.e., npm view <package_name> versions --json).
    • Note: There may be a slight delay between when the workflow finished and when NPM reports the package version as being published. If it doesn't appear right away in the above command, try again in a few minutes.

@codecov
Copy link

codecov bot commented Jun 8, 2023

Codecov Report

Merging #338 (fa9c1d0) into master (c0edbaa) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #338   +/-   ##
=======================================
  Coverage   78.26%   78.26%           
=======================================
  Files          34       34           
  Lines         667      667           
  Branches      172      172           
=======================================
  Hits          522      522           
  Misses        132      132           
  Partials       13       13           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c0edbaa...fa9c1d0. Read the comment docs.

@BilalQamar95 BilalQamar95 marked this pull request as ready for review July 3, 2023 10:00
@BilalQamar95 BilalQamar95 marked this pull request as draft July 3, 2023 10:59
@BilalQamar95 BilalQamar95 marked this pull request as ready for review July 4, 2023 12:29
@BilalQamar95 BilalQamar95 self-assigned this Jul 4, 2023
Copy link
Member

@adamstankiewicz adamstankiewicz left a comment

Choose a reason for hiding this comment

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

1 question and a handful of nits.

"@fortawesome/react-fontawesome": "^0.1.4",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"@fortawesome/react-fontawesome": "^0.2.0",
Copy link
Member

Choose a reason for hiding this comment

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

[curious] Why does this peer dependency need to be updated when ^0.1.4 should already allow 0.2.0. Is there something in v0.2.0 that is necessary? Otherwise, this is technically a breaking change for any consumers that install < 0.2.0.

Copy link
Contributor Author

@BilalQamar95 BilalQamar95 Jul 14, 2023

Choose a reason for hiding this comment

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

Mainly react-fontawesome now supports forwardRef for version 0.2.x or above which is a breaking change for React version older than 16.3.0. Since we intend to merge this as a breaking change (mentioned in PR description), I updated this as well. Also "@fortawesome/react-fontawesome": "^0.1.4" resulted in Unable to resolve path to module '@fortawesome/react-fontawesome' which was also resolved with the update.

Copy link
Member

Choose a reason for hiding this comment

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

Mainly react-fontawesome now supports forwardRef for version 0.2.x or above which is a breaking change for React version older than 16.3.0.

[clarification] On master, the minimum version of React specified in the repo's peerDependencies is ^16.12.0. Anything to do with React versions older than 16.3.0 should be irrelevant for this repository? For example, if the peer dependency is left as is at ^0.1.4, a consuming MFE like frontend-app-learner-portal-enterprise can still upgrade to ^0.2.0 on their own without causing any issues since its minimum React version is beyond the impacted version.

Also "@fortawesome/react-fontawesome": "^0.1.4" resulted in Unable to resolve path to module '@fortawesome/react-fontawesome' which was also resolved with the update.

Hm, I can't replicate this issue on master or this PR when installing 0.2.0 in devDeps but left the peer dependency unchanged 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Since we intend to merge this as a breaking change (mentioned in PR description)

Because the peerDependency is supporting both React 16 and 17 together, we're saying this library supports either React 16 or React 17. Introducing support for both 16 and 17 together in the peer dependency like this is not a breaking change. If we needed to remove React 16 from the peer dependency list, that would be a breaking change.

When some other libraries (e.g., Paragon) added support for React 17, it was added alongside React 16 and no major version / breaking change was released (example PR).

When it comes to upgrading React 18, that will definitely have issues where we'll have to likely drop support for React 16 (and possibly 17) at that time; IMHO only then should a React upgrade trigger the major version bump since we're saying consuming can run either React 16 or React 17 as is, which is not a breaking change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

[clarification] On master, the minimum version of React specified in the repo's peerDependencies is ^16.12.0. Anything to do with React versions older than 16.3.0 should be irrelevant for this repository? For example, if the peer dependency is left as is at ^0.1.4, a consuming MFE like frontend-app-learner-portal-enterprise can still upgrade to ^0.2.0 on their own without causing any issues since its minimum React version is beyond the impacted version.

Yes, versions older than 16.3.0 would be irrelevant for this repo, I may have misinterpreted your first comment, my bad. What you said here makes sense, I have updated the peerDependency for @fortawesome/react-fontawesome

Hm, I can't replicate this issue on master or this PR when installing 0.2.0 in devDeps but left the peer dependency unchanged 🤔

There was a lint failure which you can find in actions here, thats if the devDep is set to ^0.1.4, wasn't related to peerDependencies

packages/catalog-search/package.json Show resolved Hide resolved
packages/hotjar/package.json Show resolved Hide resolved
packages/logistration/package.json Show resolved Hide resolved
packages/utils/package.json Show resolved Hide resolved
@BilalQamar95 BilalQamar95 force-pushed the bilalqamar95/react-upgrade-to-v17 branch from ba26467 to 382b9d8 Compare July 14, 2023 10:04
@BilalQamar95
Copy link
Contributor Author

I have also updated paragon to the latest version, also we would like for this to go as a breaking change as mentioned in the description.

"@fortawesome/free-solid-svg-icons": "5.8.1",
"@fortawesome/react-fontawesome": "0.1.4",
"@fortawesome/react-fontawesome": "^0.2.0",
Copy link
Member

Choose a reason for hiding this comment

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

nit: most of our deps are pinned (i.e., remove the ^).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I have pinned the version

"@fortawesome/react-fontawesome": "^0.1.4",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"@fortawesome/react-fontawesome": "^0.2.0",
Copy link
Member

Choose a reason for hiding this comment

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

Mainly react-fontawesome now supports forwardRef for version 0.2.x or above which is a breaking change for React version older than 16.3.0.

[clarification] On master, the minimum version of React specified in the repo's peerDependencies is ^16.12.0. Anything to do with React versions older than 16.3.0 should be irrelevant for this repository? For example, if the peer dependency is left as is at ^0.1.4, a consuming MFE like frontend-app-learner-portal-enterprise can still upgrade to ^0.2.0 on their own without causing any issues since its minimum React version is beyond the impacted version.

Also "@fortawesome/react-fontawesome": "^0.1.4" resulted in Unable to resolve path to module '@fortawesome/react-fontawesome' which was also resolved with the update.

Hm, I can't replicate this issue on master or this PR when installing 0.2.0 in devDeps but left the peer dependency unchanged 🤔

packages/catalog-search/package.json Show resolved Hide resolved
"@fortawesome/react-fontawesome": "^0.1.4",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"@fortawesome/react-fontawesome": "^0.2.0",
Copy link
Member

Choose a reason for hiding this comment

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

Since we intend to merge this as a breaking change (mentioned in PR description)

Because the peerDependency is supporting both React 16 and 17 together, we're saying this library supports either React 16 or React 17. Introducing support for both 16 and 17 together in the peer dependency like this is not a breaking change. If we needed to remove React 16 from the peer dependency list, that would be a breaking change.

When some other libraries (e.g., Paragon) added support for React 17, it was added alongside React 16 and no major version / breaking change was released (example PR).

When it comes to upgrading React 18, that will definitely have issues where we'll have to likely drop support for React 16 (and possibly 17) at that time; IMHO only then should a React upgrade trigger the major version bump since we're saying consuming can run either React 16 or React 17 as is, which is not a breaking change.

@BilalQamar95 BilalQamar95 merged commit b1b548c into master Jul 20, 2023
@BilalQamar95 BilalQamar95 deleted the bilalqamar95/react-upgrade-to-v17 branch July 20, 2023 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants