fix: avoid ref access in useId#1078
Merged
Merged
Conversation
doistbot
reviewed
Jun 19, 2026
doistbot
left a comment
Member
There was a problem hiding this comment.
This PR fixes the React Compiler violation in the local useId helper by swapping the render-time ref mutation for a lazy useState initializer, and removes the file from the compiler violation record.
Few things worth tightening:
- Since this package already requires React 18, consider replacing the custom
useIdabstraction entirely withReact.useId()(e.g.,return providedId || React.useId()). That removes the extra state cell and consolidates ID semantics in one place rather than maintaining a deprecated second wrapper.
I also included a few optional follow-up notes in the details below.
Optional follow-up note (1)
- [P3] src/utils/common-helpers.ts:17: This fixes the compiler violation, but it also hardens a deprecated wrapper by adding state to emulate
React.useId. Since this package already requires React 18, preferconst generatedId = React.useId(); return providedId || generatedId;here instead. That removes the extra state cell and keeps ID semantics in one place instead of maintaining a seconduseIdabstraction.
bb46f99 to
f39a63e
Compare
f39a63e to
8f4cf11
Compare
doist-release-bot Bot
pushed a commit
that referenced
this pull request
Jun 19, 2026
## [33.2.1](v33.2.0...v33.2.1) (2026-06-19) ### Bug Fixes * avoid ref access in useId ([#1078](#1078)) ([4d44edf](4d44edf))
Contributor
|
🎉 This PR is included in version 33.2.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.
Summary
useIdref cache with a lazyuseStateinitializer so it no longer reads or writes refs during render.src/utils/common-helpers.tsfrom the React Compiler violation record.Closes #1067