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(react): add support for react 19 #5826

Merged
merged 11 commits into from
Dec 19, 2024
Merged

Conversation

calebpollman
Copy link
Member

@calebpollman calebpollman commented Sep 24, 2024

Description of changes

Add React 19 support for React web packages. While definitely a large PR, the bulk of the changes are changes due to the removal of the global JSX namespace in the React 19 types.

  • allow react@^19 and react-dom@^19 peer deps in React web and core packages (React Native does not support react@^19 currently), example:
- "react": "^16.14.0 || ^17.0 || ^18.0"
+ "react": "^16.14 || ^17 || ^18 || ^19"
  • update ForwardRefPrimitive interface to provide component Props and Element type generics to returned React.Element (ref). This change allows support of React 19 element typing while continuing support of React versions previous to 19.

  • update JSX.Foo -> React.JSX.Foo due to global JSX namespace removal in React 19, example:

- function SomeComponent(): JSX.Element {}
+ function SomeComponent(): React.JSX.Element {}
  • provide explicit undefined to empty useRef callsites:
- useRef()
+ useRef(undefined)
  • add "jest" and "@testing-library/jest-dom" to "types" field of tsconfig.base.json to allow usage of @testing-library/jest-dom extended jest matchers

  • update and align (where approriate) React related dev and direct dependency versions in example apps and packages:

    • [email protected] -> react@^18.3
    • @types/react@^18.2.22 -> @types/react@^18.3
    • [email protected] -> react-dom@^18.3
    • @types/react-dom@^18.2.7 -> @types/react-dom@^18.3.0
    • react-test-renderer@^18.2.0 -> react-test-renderer@^18.3.0
    • @types/react-test-renderer@^18.0.2 -> @types/react-test-renderer@^18.3.0
    • react-hook-form@"^7.43.5 -> react-hook-form@^7.53.2
    • @testing-library/react-native@^12.3.0 ->@testing-library/react-native@^12.9.0
    • @radix-ui/[email protected] -> @radix-ui/react-direction@^1.1.0
    • @radix-ui/[email protected] -> @radix-ui/react-dropdown-menu@^2.1.0
    • @radix-ui/[email protected] -> @radix-ui/react-slider@^1.2.0
  • bump StorageBrowser size thresholds due to radix dep size increases

  • remove "react-router-dom" dev dependency used in a single Link primitive unit test and the test itself
    fix typing of DropZone primitive components to no longer accept unsupported forwardRef, example (ref):

- const Accepted: Primitive<{ children?: React.ReactNode }, 'div'> = ...
+ type AcceptedType = (props: {
+   children?: React.ReactNode;
+ }) => React.JSX.Element | null;
+ const Accepted: AcceptedType = ... 
  • add "@types/emscripten" and "@types/long" to @aws-amplify/ui-react-liveness tsconfig.json (ref)

Issue #, if available

closes #6084

Description of how you validated changes

Checklist

  • Have read the Pull Request Guidelines
  • PR description included
  • yarn test passes and tests are updated/added
  • PR title and commit messages follow conventional commit syntax
  • If this change should result in a version bump, changeset added (This can be done after creating the PR.) This does not apply to changes made to docs, e2e, examples, or other private packages.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@calebpollman calebpollman requested a review from a team as a code owner September 24, 2024 00:38
Copy link

changeset-bot bot commented Sep 24, 2024

🦋 Changeset detected

Latest commit: 52c4865

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@aws-amplify/ui-react Patch
@aws-amplify/ui-react-ai Patch
@aws-amplify/ui-react-core Patch
@aws-amplify/ui-react-core-notifications Patch
@aws-amplify/ui-react-geo Patch
@aws-amplify/ui-react-liveness Patch
@aws-amplify/ui-react-native Patch
@aws-amplify/ui-react-notifications Patch
@aws-amplify/ui-react-storage Patch
@aws-amplify/ui-react-auth Patch
@aws-amplify/ui-react-core-auth Patch
@aws-amplify/ui-react-native-auth Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@calebpollman calebpollman changed the title chore(react): update react & react-dom types pre-react 19 [WIP} chore(react): add support for react 19 Dec 6, 2024
@calebpollman calebpollman marked this pull request as draft December 6, 2024 02:22
@calebpollman calebpollman force-pushed the react/bump-react-types branch from 1721702 to 3a8fc36 Compare December 16, 2024 23:47
@calebpollman calebpollman changed the title [WIP} chore(react): add support for react 19 [WIP] chore(react): add support for react 19 Dec 16, 2024
@calebpollman calebpollman force-pushed the react/bump-react-types branch 4 times, most recently from b860b9e to 78ba219 Compare December 17, 2024 01:28
@calebpollman calebpollman force-pushed the react/bump-react-types branch from 78ba219 to 6da6e66 Compare December 17, 2024 02:04
@@ -17,6 +17,7 @@ const ViewPrimitive: Primitive<ViewProps, 'div'> = (
isDisabled,
style,
inert,

Copy link
Member

Choose a reason for hiding this comment

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

Info: is this extra line separating ...rest intentional?

@calebpollman calebpollman changed the title [WIP] chore(react): add support for react 19 chore(react): add support for react 19 Dec 19, 2024
@calebpollman calebpollman merged commit 954e9be into main Dec 19, 2024
37 checks passed
@calebpollman calebpollman deleted the react/bump-react-types branch December 19, 2024 22:32
@github-actions github-actions bot mentioned this pull request Dec 19, 2024
@morganney
Copy link

I'm still seeing older versions of dependencies that don't support React 19:

morganney@macos openai-realtime (feat/amplify-authn) $ npm ls react-dom
[email protected] /Users/morganney/code/openai-realtime
└─┬ [email protected] -> ./packages/ui
  ├─┬ @aws-amplify/[email protected]
  │ ├─┬ @radix-ui/[email protected]
  │ │ ├─┬ @radix-ui/[email protected]
  │ │ │ ├─┬ @radix-ui/[email protected]
  │ │ │ │ └── [email protected] deduped
  │ │ │ ├─┬ @radix-ui/[email protected]
  │ │ │ │ └── [email protected] deduped
  │ │ │ ├─┬ @radix-ui/[email protected]
  │ │ │ │ ├─┬ @floating-ui/[email protected]
  │ │ │ │ │ └── [email protected] deduped
  │ │ │ │ ├─┬ @radix-ui/[email protected]
  │ │ │ │ │ └── [email protected] deduped
  │ │ │ │ └── [email protected] deduped
  │ │ │ ├─┬ @radix-ui/[email protected]
  │ │ │ │ └── [email protected] deduped
  │ │ │ ├─┬ @radix-ui/[email protected]
  │ │ │ │ └── [email protected] deduped
  │ │ │ ├─┬ @radix-ui/[email protected]
  │ │ │ │ └── [email protected] deduped
  │ │ │ └── [email protected] deduped
  │ │ ├─┬ @radix-ui/[email protected]
  │ │ │ └── [email protected] deduped
  │ │ └── [email protected] deduped
  │ ├─┬ @radix-ui/[email protected]
  │ │ ├─┬ @radix-ui/[email protected]
  │ │ │ └── [email protected] deduped
  │ │ └── [email protected] deduped
  │ └── [email protected]
  ├── [email protected]
  └─┬ [email protected]
    └── [email protected] deduped

When running npm install you'll see npm warn ERESOLVE overriding peer dependency.

I'm running:

morganney@macos openai-realtime (feat/amplify-authn) $ node -v
v22.12.0
morganney@macos openai-realtime (feat/amplify-authn) $ npm -v
10.9.0 

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.

react 19 support
6 participants