Skip to content

Conversation

@danielguillan
Copy link
Contributor

@danielguillan danielguillan commented Dec 1, 2025

Towards https://github.com/github/primer/issues/6134

Upgrades doctocat-nextjs to support React 19 and updates Primer Brand to v0.60.0. The changes ensure static builds work correctly with React 19 while maintaining backwards compatibility with React 18.

Key Changes

  • React 19 support: Updated peer dependencies to accept React 18 or 19, and regenerated package-lock.json to resolve version mismatch issues during SSR
  • Primer Brand upgrade: Updated @primer/react-brand from an earlier version to v0.60.1
  • Type fixes: Fixed TypeScript issues in components (AccessibilityLabel, ReadinessLabel, ReactCodeBlock, NavDrawer, getRelatedPages)
  • ESLint dependencies: Added eslint-plugin-prettier and @typescript-eslint/eslint-plugin as direct dependencies (previously transitive, no longer hoisted after lock file regeneration)

@danielguillan danielguillan force-pushed the danielguillan/upgrade-primer-brand-and-react-v19+ branch from 231d77b to d4dadd3 Compare December 3, 2025 14:20
@danielguillan danielguillan marked this pull request as ready for review December 3, 2025 14:24
@danielguillan danielguillan requested a review from a team as a code owner December 3, 2025 14:24
Copilot AI review requested due to automatic review settings December 3, 2025 14:24
Copy link
Contributor

Copilot AI left a 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-brand from v0.54.0 to v0.60.1, requiring migration from Label to Token component
  • Added explicit as props 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.

@danielguillan danielguillan force-pushed the danielguillan/upgrade-primer-brand-and-react-v19+ branch from c1e7bef to e064c35 Compare December 4, 2025 10:21
'doctocat-nextjs-site': minor
---

Add React 19 support
Copy link
Collaborator

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.

Copy link
Contributor Author

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'
Copy link
Collaborator

Choose a reason for hiding this comment

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

TIL

Copy link
Collaborator

@rezrah rezrah left a 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

@danielguillan danielguillan merged commit a06099d into main Dec 4, 2025
10 checks passed
@primer-css primer-css mentioned this pull request Dec 4, 2025
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.

3 participants