Skip to content

refactor: add return early to useMergedRefs#7843

Open
joshblack wants to merge 6 commits into
mainfrom
feat/add-react-major-version-to-env
Open

refactor: add return early to useMergedRefs#7843
joshblack wants to merge 6 commits into
mainfrom
feat/add-react-major-version-to-env

Conversation

@joshblack
Copy link
Copy Markdown
Member

Add support for detecting the major version for React so that we can easily toggle on functionality supported in React 19 vs 18.

Changelog

New

Changed

  • Update environment.js to environment.ts
  • Update useMergedRefs to return early if React <19 (helps to prevent console warnings in React 18 for clean up functions)

Removed

Rollout strategy

  • Patch release

Copilot AI review requested due to automatic review settings May 15, 2026 15:59
@joshblack joshblack requested a review from a team as a code owner May 15, 2026 15:59
@joshblack joshblack requested a review from TylerJDev May 15, 2026 15:59
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 15, 2026

🦋 Changeset detected

Latest commit: 0adf41d

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 Patch

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 staff Author is a staff member integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels May 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.

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

Copy link
Copy Markdown
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

Converts environment.js to TypeScript, adds reactMajorVersion detection, and short-circuits the useMergedRefs cleanup function on React <19 to suppress the React 18 warning about cleanup functions being ignored.

Changes:

  • Rename utils/environment.jsutils/environment.ts and export reactMajorVersion parsed from React's version string.
  • In useMergedRefs, return early before the cleanup function when running on React <19.
  • Add patch-level changeset.
Show a summary per file
File Description
packages/react/src/utils/environment.ts New TS module exporting canUseDOM and reactMajorVersion.
packages/react/src/utils/environment.js Old JS file removed (replaced by .ts).
packages/react/src/hooks/useMergedRefs.ts Skips returning the ref cleanup function on React <19.
.changeset/dull-berries-call.md Patch changeset documenting the React 18 warning fix.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 0

@primer
Copy link
Copy Markdown
Contributor

primer Bot commented May 15, 2026

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

Copilot AI and others added 2 commits May 15, 2026 16:12
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
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 staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants