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): upgrade to React 19 #332

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Conversation

drichar
Copy link
Collaborator

@drichar drichar commented Jan 9, 2025

Description

This PR upgrades the React dependencies to version 19 across all packages and applies the official React 19 codemods to ensure compatibility with the new version.

Details

  • Upgrade core React dependencies:
    • react and react-dom to 19.0.0
    • @types/react and @types/react-dom to 19.0.0
    • Update peer dependency ranges to include ^19.0.0
  • Upgrade supporting libraries for React 19 compatibility:
    • @testing-library/react to 16.1.0
    • TanStack store packages to 0.7.0
  • Apply official React 19 codemods:
    • remove-context-provider: Simplify Context.Provider syntax
    • use-context-hook: Migrate from useContext to use hook
    • scoped-jsx: Update JSX namespace imports

Update React and related dependencies to version 19:
- Upgrade `react` and `react-dom` to 19.0.0
- Upgrade `@types/react` and `@types/react-dom` to 19.0.0
- Update peer dependency ranges to include ^19.0.0
- Upgrade `@testing-library/react` to 16.1.0
- Upgrade TanStack store packages to 0.7.0 for React 19 support
Apply React 19 codemod `remove-context-provider` to simplify `Context.Provider`
syntax by removing redundant wrapper element in `WalletProvider` component
Apply React 19 codemod `use-context-hook` to replace `useContext` with the new
`use` hook in `useWallet` hook
Apply React 19 codemod `scoped-jsx` to update `JSX.Element` to use scoped
`React.JSX.Element` namespace in `WalletProvider` component
@drichar
Copy link
Collaborator Author

drichar commented Jan 10, 2025

One of the breaking changes in v19 is the ReactNode type. As a result, the WalletProvider exported by use-wallet-react built with React v19 cannot accept an explicitly typed children prop from a React v18 (or lower) project.

A common pattern in Next.js App Router projects is a client component containing all of the root context providers, like the one in our Next.js example app:

export function Providers({ children }: { children: React.ReactNode }) {
return <WalletProvider manager={walletManager}>{children}</WalletProvider>
}

The resulting error can be seen in this CI run: https://github.com/TxnLab/use-wallet/actions/runs/12699514184/job/35400307744?pr=332

If children is implicitly typed, there's no error. But there are bound to be other Next.js projects that follow the providers pattern, and other situations where explicit types are used. I'll need to determine a workaround or wait until React v19 is more widely adopted before moving forward with this upgrade.

@drichar drichar marked this pull request as draft January 17, 2025 04:15
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.

1 participant