Skip to content

fix: avoid ref access in useId#1078

Merged
henningmu merged 1 commit into
mainfrom
henningmu/fix-reactist-1067
Jun 19, 2026
Merged

fix: avoid ref access in useId#1078
henningmu merged 1 commit into
mainfrom
henningmu/fix-reactist-1067

Conversation

@henningmu

@henningmu henningmu commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace the deprecated local useId ref cache with a lazy useState initializer so it no longer reads or writes refs during render.
  • Remove src/utils/common-helpers.ts from the React Compiler violation record.

Closes #1067

@henningmu henningmu self-assigned this Jun 19, 2026
@henningmu henningmu changed the title Fix useId React Compiler violation fix(common-helpers): avoid ref access in useId Jun 19, 2026

@doistbot doistbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 useId abstraction entirely with React.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, prefer const 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 second useId abstraction.

Share FeedbackReview Logs

@henningmu henningmu force-pushed the henningmu/fix-reactist-1067 branch from bb46f99 to f39a63e Compare June 19, 2026 18:29
@henningmu henningmu changed the title fix(common-helpers): avoid ref access in useId fix: avoid ref access in useId Jun 19, 2026
@henningmu henningmu force-pushed the henningmu/fix-reactist-1067 branch from f39a63e to 8f4cf11 Compare June 19, 2026 18:33
@henningmu henningmu merged commit 4d44edf into main Jun 19, 2026
10 checks passed
@henningmu henningmu deleted the henningmu/fix-reactist-1067 branch June 19, 2026 18:36
@henningmu henningmu requested review from a team and Bloomca and removed request for a team June 19, 2026 18:36
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))
@doist-release-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 33.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@doist-release-bot doist-release-bot Bot added the Released PRs that have been merged and released label Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Released PRs that have been merged and released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: Fix React Compiler violations in useId (common-helpers)

2 participants