Skip to content

Enable React Compiler for Portal (lazy-ref → useState)#8119

Closed
mattcosta7 wants to merge 49 commits into
react-compiler-migrate-all-prepfrom
migrate/portal
Closed

Enable React Compiler for Portal (lazy-ref → useState)#8119
mattcosta7 wants to merge 49 commits into
react-compiler-migrate-all-prepfrom
migrate/portal

Conversation

@mattcosta7

Copy link
Copy Markdown
Contributor

Closes #

Enable React Compiler for Portal

Note

Depends on / based on the migration foundation PR (base branch react-compiler-migrate-all-prep). Diff shown here is Portal-only.

Portal was on the React Compiler unsupportedPatterns allowlist because it read/wrote a ref during render (two react-hooks/refs disables) to lazily create its container <div>. This replaces that with the canonical useState lazy-initializer, which obeys the Rules of React, then removes Portal from the allowlist so it's compiled.

- const elementRef = React.useRef<HTMLDivElement | null>(null)
- // eslint-disable-next-line react-hooks/refs
- if (!elementRef.current) { ... elementRef.current = div }
- // eslint-disable-next-line react-hooks/refs
- const element = elementRef.current
+ const [element] = React.useState<HTMLDivElement>(() => { ...; return div })

Net −3 lines, no behavior change (the container is still created once and reused; SSR profile is identical since the original also created the element during render).

Validation

  • eslint src/Portal/Portal.tsx passes with no react-hooks/refs disables.
  • Portal test suite passes compiled (9/9).

Rollout

  • Patch release

Merge checklist

  • Added/updated tests (existing suite runs compiled)
  • Changes are SSR compatible

Copilot AI and others added 30 commits June 24, 2026 18:00
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: Josh Black <joshblack@github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
…formance/code quality (#7506)

Co-authored-by: Tyler Jones <tylerjdev@github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: iansan5653 <2294248+iansan5653@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: hectahertz <24622853+hectahertz@users.noreply.github.com>
Co-authored-by: Jon Rohan <yes@jonrohan.codes>
Co-authored-by: jonrohan <54012+jonrohan@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: iansan5653 <2294248+iansan5653@users.noreply.github.com>
Co-authored-by: Ian Sanders <iansan5653@github.com>
Co-authored-by: primer[bot] <119360173+primer[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…7.2.0 (#8077)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
… and SideNav (#8052)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jonrohan <54012+jonrohan@users.noreply.github.com>
Co-authored-by: Jon Rohan <yes@jonrohan.codes>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…pdates (#8102)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Copilot AI and others added 4 commits July 2, 2026 21:01
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: Josh Black <joshblack@github.com>
Co-authored-by: primer[bot] <119360173+primer[bot]@users.noreply.github.com>
Co-authored-by: Marie Lucca <40550942+francinelucca@users.noreply.github.com>
Co-authored-by: Manuel Puyol <manuelpuyol@github.com>
@changeset-bot

changeset-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 806aa6a

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

@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 Jul 6, 2026
@github-actions

github-actions Bot commented Jul 6, 2026

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. If this doesn't work, you can also use the original workflow here. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

To publish a canary release for integration testing, apply the Canary Release label to this PR.

@github-actions github-actions Bot requested a deployment to storybook-preview-8119 July 6, 2026 16:43 Abandoned
@primer

primer Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

🤖 Lint issues have been automatically fixed and committed to this PR.

joshblack and others added 5 commits July 6, 2026 17:20
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: Josh Black <joshblack@github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
# Conflicts:
#	packages/react/script/react-compiler.mjs
@mattcosta7 mattcosta7 added the skip changeset This change does not need a changelog label Jul 7, 2026 — with GitHub Codespaces
@github-actions github-actions Bot temporarily deployed to storybook-preview-8119 July 7, 2026 15:14 Inactive
dependabot Bot added 2 commits July 7, 2026 16:08
…8130)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…rybook group (#8129)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@mattcosta7 mattcosta7 self-assigned this Jul 7, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants