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

fix: Update react-virtual with patch to support React 18 #1765

Closed
wants to merge 2 commits into from

Conversation

cubeddu
Copy link

@cubeddu cubeddu commented Nov 29, 2023

Description

This PR introduces a temporary workaround to address the compatibility issue with React 18 in the react-virtual package, a dependency of @cloudscape-design/components. The core of the issue is that react-virtual specifies peer dependencies that do not include React 18, leading to an unmet peer dependency error in environments using the latest version of React:

└─┬ @cloudscape-design/components 3.0.0
  └─┬ react-virtual 2.10.4
    └── ✕ unmet peer react@"^16.6.3 || ^17.0.0": found 18.2.0

Given that the library maintainer has yet to release a version of react-virtual with official support for React 18 (TanStack/virtual#278, TanStack/virtual#568), this PR implements a patch as a temporary measure.

Changes:

Patch File Creation (react-virtual.patch): A new patch file has been created that modifies the package.json of react-virtual to include || ^18.0.0 in the peerDependencies section for React. This allows the library to recognize React 18 as a valid peer dependency.

Patch Diff:

diff -ruN node_modules/react-virtual-original/package.json node_modules/react-virtual/package.json
--- node_modules/react-virtual-original/package.json	2023-11-22 15:29:57
+++ node_modules/react-virtual/package.json	2023-11-22 15:35:43
@@ -44,7 +44,7 @@
    "@reach/observe-rect": "^1.1.0"
  },
  "peerDependencies": {
-    "react": "^16.6.3 || ^17.0.0"
+    "react": "^16.6.3 || ^17.0.0 || ^18.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.8.6",

Modification to package.json: The project's package.json has been updated to include "postinstall": "patch-package". This addition ensures the patch is applied automatically post-installation.

New Dependency (patch-package): The patch-package package has been added to the project. This package allows us to apply patches to node modules easily, facilitating this temporary workaround.

Rationale:

Implementing this patch allows us to continue using @cloudscape-design/components with React 18 without waiting for an official update from react-virtual. It's a straightforward, low-risk solution to maintain compatibility and ensure smooth project progress.

Next Steps:

We will monitor the upstream react-virtual repository for an official release that includes React 18 support. Once available, we can revert this patch and update the dependency accordingly.

Related links, issue #, if available: n/a

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@cubeddu cubeddu requested a review from a team as a code owner November 29, 2023 18:15
@cubeddu cubeddu requested review from taheramr and removed request for a team November 29, 2023 18:15
@cubeddu cubeddu changed the title Update react-virtual with patch to support React 18 fix: Update react-virtual with patch to support React 18 Nov 29, 2023
@pan-kot pan-kot self-requested a review November 30, 2023 13:24
@carlos-affinidi
Copy link

react-virtual with support for React 18 is released under @tanstack/react-virtual

@cubeddu cubeddu closed this Dec 8, 2023
iFreilicht added a commit to iFreilicht/kbar that referenced this pull request Dec 10, 2023
react-virtual is now available as v3 and published under
@tanstack/react-virtual. The old version will not receive updates
anymore, see cloudscape-design/components#1765 (comment).

Fixes timc1#330
iFreilicht added a commit to iFreilicht/kbar that referenced this pull request Dec 10, 2023
react-virtual is now available as v3 and published under
@tanstack/react-virtual. The old version will not receive updates
anymore, see cloudscape-design/components#1765 (comment).

Fixes timc1#330
@just-boris
Copy link
Member

Hello, just to close up on this thread, the proposed change does not fix anything. It updates our own PR build process, but changes nothing in the output artifacts, because your build pulls the original react-virtual instance from NPM registry in any way.

To fix installation issues you can use npm install --force to resolve peer dependencies issue. This is how we do that in our own builds:

https://github.com/cloudscape-design/actions/blob/eec641612542360339a84cef3cd578c698b80e0b/.github/workflows/release.yml#L33

Haarolean added a commit to Haarolean/kbar that referenced this pull request Jan 12, 2024
commit 51879c7
Author: Felix Uhl <github@mail.felix-uhl.de>
Date:   Sun Dec 10 17:15:24 2023 +0100

    Fix type error

commit a19a064
Author: Felix Uhl <github@mail.felix-uhl.de>
Date:   Sun Dec 10 15:29:40 2023 +0100

    Upgrade to react-virtual 3.0.1

    react-virtual is now available as v3 and published under
    @tanstack/react-virtual. The old version will not receive updates
    anymore, see cloudscape-design/components#1765 (comment).

    Fixes timc1#330
iFreilicht added a commit to iFreilicht/kbar that referenced this pull request Mar 2, 2024
react-virtual is now available as v3 and published under
@tanstack/react-virtual. The old version will not receive updates
anymore, see cloudscape-design/components#1765 (comment).

Fixes timc1#330
iFreilicht added a commit to iFreilicht/kbar that referenced this pull request Mar 2, 2024
react-virtual is now available as v3 and published under
@tanstack/react-virtual. The old version will not receive updates
anymore, see cloudscape-design/components#1765 (comment).

Fixes timc1#330
iFreilicht added a commit to iFreilicht/kbar that referenced this pull request Mar 2, 2024
react-virtual is now available as v3 and published under
@tanstack/react-virtual. The old version will not receive updates
anymore, see cloudscape-design/components#1765 (comment).

Fixes timc1#330
iFreilicht added a commit to iFreilicht/kbar that referenced this pull request Mar 2, 2024
react-virtual is now available as v3 and published under
@tanstack/react-virtual. The old version will not receive updates
anymore, see cloudscape-design/components#1765 (comment).

Fixes timc1#330
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.

None yet

3 participants