-
Notifications
You must be signed in to change notification settings - Fork 2
Upgrade to React v19 #73
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
Upgrade to React v19 #73
Conversation
231d77b to
d4dadd3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR upgrades the codebase to support React 19 while maintaining backwards compatibility with React 18. The changes include dependency updates, TypeScript type fixes for stricter React 19 types, and component API migrations to align with updated Primer library versions.
- Updated React and TypeScript types to v19
- Upgraded
@primer/react-brandfrom v0.54.0 to v0.60.1, requiring migration fromLabeltoTokencomponent - Added explicit
asprops to polymorphic Primer components for React 19 type compatibility - Added ESLint dependencies that are no longer transitively hoisted
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/theme/package.json | Updated dependencies: removed React from dependencies (keeping in peerDependencies), upgraded framer-motion and react-focus-on, updated @types/react and @types/react-dom to v19, removed overrides section |
| packages/site/package.json | Upgraded React to v19.2.0, @primer/react-brand to v0.60.1, and added @types/react and @types/react-dom v19 as dev dependencies |
| package.json | Upgraded @primer/react-brand to v0.60.1 and added previously transitive ESLint dependencies (@typescript-eslint/eslint-plugin, eslint-plugin-prettier) |
| packages/theme/components/layout/related-content-links/getRelatedPages.tsx | Fixed TypeScript error by adding explicit type assertion for React element props to safely access children property |
| packages/theme/components/layout/code-block/ReactCodeBlock.tsx | Fixed TypeScript error in helper function with explicit type assertion for React element props |
| packages/theme/components/layout/nav-drawer/NavDrawer.tsx | Added explicit as="button" prop to IconButton for React 19 polymorphic component typing |
| packages/theme/components/layout/header/Header.tsx | Added explicit as="button" prop to all IconButton instances for React 19 compatibility |
| packages/theme/components/layout/global-search/GlobalSearch.tsx | Added explicit as="input" prop to TextInput for React 19 polymorphic component typing |
| packages/theme/components/layout/article/ReadinessLabel.tsx | Migrated from Label to Token component API, adding aria-hidden to icon for proper accessibility |
| packages/theme/components/layout/article/ReadinessLabel.module.css | Removed CSS properties now handled by Token component, added !important to color override |
| packages/theme/components/layout/article/AccessibilityLabel.tsx | Migrated from Label to Token component API, adding aria-hidden to icon for proper accessibility |
| packages/theme/components/layout/article/AccessibilityLabel.module.css | Removed CSS properties now handled by Token component, added !important to color override |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c1e7bef to
e064c35
Compare
| 'doctocat-nextjs-site': minor | ||
| --- | ||
|
|
||
| Add React 19 support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danielguillan do you know if this is still backwards compatible with React 18? I think it's fine if it's not, but we should make that clear here that it's a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the update is backward compatible with React 18. But since it updates @primer/react to version 38, there may be potential incompatibilities for users relying on features from versions earlier than 38 (e.g., Box component, sx prop). I have noted this in the changeset.
| 'use client' | ||
| import React from 'react' | ||
| import {Label} from '@primer/react' | ||
| import {Token} from '@primer/react' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL
rezrah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor feedback. ✅ to unblock. Thanks @danielguillan ⭐
Towards https://github.com/github/primer/issues/6134
Upgrades
doctocat-nextjsto support React 19 and updates Primer Brand tov0.60.0. The changes ensure static builds work correctly with React 19 while maintaining backwards compatibility with React 18.Key Changes
package-lock.jsonto resolve version mismatch issues during SSR@primer/react-brandfrom an earlier version to v0.60.1AccessibilityLabel,ReadinessLabel,ReactCodeBlock,NavDrawer,getRelatedPages)eslint-plugin-prettierand@typescript-eslint/eslint-pluginas direct dependencies (previously transitive, no longer hoisted after lock file regeneration)