fix(useElementIds): prevent Webpack static analysis issue with useId#1676
Merged
silviuaavram merged 2 commits intomasterfrom Feb 13, 2026
Merged
fix(useElementIds): prevent Webpack static analysis issue with useId#1676silviuaavram merged 2 commits intomasterfrom
silviuaavram merged 2 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses React 16/17 build failures in Webpack caused by static analysis of React.useId by isolating the useId access behind computed property access and an indirection, while also relocating useElementIds into dedicated TypeScript modules.
Changes:
- Move dropdown
useElementIdsout ofsrc/hooks/utils.jsintosrc/hooks/utils.dropdown/useElementIds.tsand update consumers (useSelect,useCombobox). - Avoid
React.useIddirect member access by using an indirectReact['useId']reference. - Add/adjust tests around the moved hook.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/hooks/utils.js | Removes the inline useElementIds implementation/export to centralize it elsewhere. |
| src/hooks/utils.dropdown/useElementIds.ts | New TS implementation of dropdown useElementIds with indirect useId access. |
| src/hooks/utils.dropdown/tests/useElementIds.test.ts | Adds unit tests for memoization behavior of the moved hook. |
| src/hooks/utils.dropdown/tests/useElementIds.r18.test.ts | Updates import to point at the new module. |
| src/hooks/utils.dropdown/tests/useElementIds.legacy.test.ts | Updates import and mocks to point at the new module. |
| src/hooks/useTagGroup/utils/useElementIds.ts | Switches useId access to indirection and refactors memoization strategy. |
| src/hooks/useTagGroup/utils/index.ts | Simplifies re-exports to only export useElementIds value. |
| src/hooks/useSelect/index.js | Updates useElementIds import to new module. |
| src/hooks/useCombobox/index.js | Updates useElementIds import to new module. |
| src/hooks/tests/utils.test.js | Removes useElementIds tests from the old utils location. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🎉 This PR is included in version 9.3.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
What
Prevent Webpack static analysis from parsing the React.useId reference. Using
Why
Fix #1674.
How
Use a variable to keep React['useId'] reference.
Changes
Checklist