Skip to content

fix(useElementIds): prevent Webpack static analysis issue with useId#1676

Merged
silviuaavram merged 2 commits intomasterfrom
fix/use-id-static-analysis
Feb 13, 2026
Merged

fix(useElementIds): prevent Webpack static analysis issue with useId#1676
silviuaavram merged 2 commits intomasterfrom
fix/use-id-static-analysis

Conversation

@silviuaavram
Copy link
Collaborator

@silviuaavram silviuaavram commented Feb 13, 2026

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

  • Use React['useId'] instead of React.useId.
  • Migrate to TypeScript.

Checklist

  • Documentation
  • Tests
  • TypeScript Types
  • Ready to be merged

Copy link

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

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 useElementIds out of src/hooks/utils.js into src/hooks/utils.dropdown/useElementIds.ts and update consumers (useSelect, useCombobox).
  • Avoid React.useId direct member access by using an indirect React['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.

@silviuaavram silviuaavram merged commit 9e79c4e into master Feb 13, 2026
4 checks passed
@silviuaavram silviuaavram deleted the fix/use-id-static-analysis branch February 13, 2026 18:31
@github-actions
Copy link

🎉 This PR is included in version 9.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

React 16/17 compatibility broken in v9.1.0+ due to static analysis of React.useId()

1 participant