Skip to content

perf(react-compiler): enable controlled state and outside-click hooks - #8558

Merged
joshblack merged 1 commit into
joshblack/react-compiler-underline-panelsfrom
joshblack/react-compiler-hooks
Oct 20, 2026
Merged

joshblack merged 1 commit into
joshblack/react-compiler-underline-panelsfrom
joshblack/react-compiler-hooks

Conversation

@joshblack

@joshblack joshblack commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Follow up to #8555. Enable React Compiler for useControllableState, useOnOutsideClick, and our internal development-only effect hook.

Keep the hooks that need broader dependency or focus-lifecycle changes excluded.

Changelog

New

Changed

  • Capture the initial controlled/uncontrolled mode in state instead of reading a ref during render. The mode remains fixed for the hook's lifetime.
  • Allocate outside-click handler IDs through lazy state initialization, preserving numeric priority for nested handlers.
  • Select the development-only effect implementation at module initialization: React's effect hook in development and a no-op in production.
  • Remove the three compiler exclusions and add a minor changeset, matching our recent compiler rollout.

Removed

Rollout strategy

  • No changes needed in github/github-ui
  • Needs changes in github/github-ui
  • Ships with feature flag(s)
  • Not sure
  • None

@changeset-bot

changeset-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8717c36

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

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

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

@joshblack
joshblack added this pull request to stack #8559 October 15, 2026 21:33
@github-actions github-actions Bot added the staff Author is a staff member label Oct 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

@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 15, 2026
@github-actions
github-actions Bot temporarily deployed to storybook-preview-8558 October 15, 2026 21:42 Inactive
@primer-integration

primer-integration Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Integration test results from github/github-ui PR:

Waiting  Changes   Waiting
Passed  CI   Passed
Passed  VRT   Passed
Passed  Projects   Passed

@joshblack
joshblack marked this pull request as ready for review October 16, 2026 16:05
@joshblack
joshblack requested a review from a team as a code owner October 16, 2026 16:05
@joshblack
joshblack requested review from TylerJDev and a balanced review from Copilot October 16, 2026 16:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused refactors preserve existing behavior and include targeted regression coverage; no blocking issues were identified, though tests were not executed.

0 open findings

What changed in this PR

Continues the React Compiler rollout from #8555 by enabling compilation for three hooks while preserving their existing behavior.

Changes:

  • Replace render-time ref access and memoized handler IDs with state initialization.
  • Select the development-only effect implementation at module initialization.
  • Remove compiler exclusions, add regression tests, and include a minor changeset.
File Description
packages/​react/​src/​internal/​hooks/​useDevOnlyEffect.ts Selects the effect implementation at module initialization.
packages/​react/​src/​hooks/​useOnOutsideClick.tsx Allocates stable handler IDs through lazy state.
packages/​react/​src/​hooks/​useControllableState.ts Stores the initial controlled mode in state.
packages/​react/​src/​hooks/​__tests__/​useOnOutsideClick.test.tsx Tests nested priority, cancellation, and cleanup in StrictMode.
packages/​react/​src/​hooks/​__tests__/​useControllableState.test.tsx Tests setter stability and callback freshness.
packages/​react/​script/​react-compiler.mjs Removes the three hook exclusions.
.changeset/​react-compiler-hooks.md Records compiler support as a minor release.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@joshblack joshblack added the integration-tests: skipped manually Changes in this PR do not require an integration test label Oct 20, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e632d4e3-54d2-4423-9888-8e37b00494a3
@joshblack
joshblack force-pushed the joshblack/react-compiler-hooks branch from 11cefe4 to 80f8d24 Compare October 20, 2026 16:12
@joshblack
joshblack added this pull request to the merge queue Oct 20, 2026
Merged via the queue into main with commit 6f52273 Oct 20, 2026
50 checks passed
@joshblack
joshblack deleted the joshblack/react-compiler-hooks branch October 20, 2026 16:45
@primer primer Bot mentioned this pull request Oct 20, 2026

This branch was successfully deployed

2 active deployments
storybook-preview-8558 — 80f8d24a Deployed Oct 20, 2026 by github-actions[bot]
github-pages — 80f8d24a Deployed Oct 20, 2026 by joshblack via deploy-preview #33782
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 integration-tests: skipped manually Changes in this PR do not require an integration test staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants