Skip to content

Conversation

@joshblack
Copy link
Member

Update project to use v1.0 of React Compiler

Changelog

New

Changed

  • Update dependencies for React Compiler 1.0
    • eslint-plugin-react-hooks
    • react-compiler-runtime
    • babel-plugin-react-compiler

Removed

  • Remove the eslint-plugin-react-compiler dependency in favor of the latest react hooks plugin

Rollout strategy

  • None; if selected, include a brief description as to why

Copilot AI review requested due to automatic review settings October 31, 2025 17:28
@joshblack joshblack requested a review from a team as a code owner October 31, 2025 17:28
@joshblack joshblack requested a review from jonrohan October 31, 2025 17:28
@changeset-bot
Copy link

changeset-bot bot commented Oct 31, 2025

⚠️ No Changeset found

Latest commit: db8df9d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@joshblack joshblack added the skip changeset This change does not need a changelog label Oct 31, 2025
@github-actions github-actions bot added the staff Author is a staff member label Oct 31, 2025
@github-actions
Copy link
Contributor

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Oct 31, 2025
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 pull request upgrades the React Hooks ESLint plugin from version 5.2.0 to 7.0.1 and replaces the React Compiler plugin with the new hooks plugin. The upgrade introduces new lint rules that detect React patterns that conflict with the React Compiler, requiring updates to eslint-disable comments throughout the codebase.

  • Removes eslint-plugin-react-compiler dependency and replaces it with the enhanced eslint-plugin-react-hooks v7.0.1
  • Updates React compiler runtime and babel plugin to stable version 1.0.0
  • Adds new eslint-disable comments for newly detected React Compiler violations across ~40 files
  • Refactors some code patterns to be more compatible with React Compiler (e.g., useRenderForcingRef, ProgressBar.stories)

Reviewed Changes

Copilot reviewed 53 out of 54 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
package.json Removes eslint-plugin-react-compiler, upgrades eslint-plugin-react-hooks to v7.0.1
eslint.config.mjs Removes react-compiler plugin config, updates to use react-hooks flat config
packages/react/package.json Updates react-compiler-runtime and babel-plugin-react-compiler to stable v1.0.0
packages/react/src/hooks/useRenderForcingRef.ts Moves ref.current assignment from render to useEffect to avoid compiler violations
packages/react/src/hooks/useMediaUnsafeSSR.tsx Refactors conditional setState from useEffect to render phase with proper guard
packages/react/src/ProgressBar/ProgressBar.stories.tsx Removes unnecessary state and useEffect, simplifies to derived variable
packages/react/src/Token/_RemoveTokenButton.tsx Removes runtime delete rest.children, uses destructuring to exclude children prop
Various component files Adds eslint-disable comments for legitimate React Compiler violations (refs, set-state-in-effect, immutability, etc.)

Comment on lines +22 to +24
useEffect(() => {
ref.current = refCurrent
}, [refCurrent])
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

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

This useEffect creates a synchronization issue. The ref is being set in both the setRef callback (line 16) and in this effect (line 23). This means ref.current could be stale between when setRef is called and when the effect runs. Since setRef already updates ref.current = newRef on line 16, this effect is redundant and could cause the ref to be set twice with potentially different values, creating race conditions.

Copilot uses AI. Check for mistakes.
Comment on lines +46 to +48
if (features[mediaQueryString] !== undefined && matches !== features[mediaQueryString]) {
setMatches(features[mediaQueryString] as boolean)
}
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

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

Calling setMatches during render (outside of useEffect) can cause infinite re-render loops if the component re-renders for any reason while features[mediaQueryString] is defined. This violates React's principle that render functions should be pure. The original useEffect pattern at lines 46-48 (before this change) was the correct approach to sync state based on context changes.

Copilot uses AI. Check for mistakes.
Comment on lines +46 to 47
// eslint-disable-next-line react-hooks/refs
{...rest}
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

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

The eslint-disable comment on line 46 disables the react-hooks/refs rule for the spread operator, but the actual issue is on line 55 where rest.ref is explicitly accessed. The disable comment should be moved to line 54 (before the ref prop) rather than line 46, as spreading rest props is not the violation—accessing rest.ref is.

Copilot uses AI. Check for mistakes.
Comment on lines +54 to 55
// eslint-disable-next-line react-hooks/refs
ref={rest.ref as React.Ref<HTMLButtonElement>}
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

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

[nitpick] With the new pattern of destructuring children: _children on line 24, the rest object no longer contains children. However, it still contains ref which is being explicitly extracted on line 55. For consistency and to avoid the eslint-disable comment, consider also destructuring ref in the function parameters: ref: forwardedRef, children: _children and then using ref={forwardedRef as React.Ref<HTMLButtonElement>}.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm skip changeset This change does not need a changelog staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants