refactor: add return early to useMergedRefs#7843
Conversation
🦋 Changeset detectedLatest commit: 0adf41d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
There was a problem hiding this comment.
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.js→utils/environment.tsand exportreactMajorVersionparsed from React'sversionstring. - 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
|
🤖 Lint issues have been automatically fixed and committed to this PR. |
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
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
environment.jstoenvironment.tsuseMergedRefsto return early if React <19 (helps to prevent console warnings in React 18 for clean up functions)Removed
Rollout strategy