Repository navigation
fix(aria): use Octane's useRef instead of the null-dropping cast - #2291
Merged
Merged
Conversation
octane now declares React 19's `useRef<T>(initial: T | null)` and `useRef<T>(initial: T | undefined)` overloads (#2281), so the compat layer no longer needs its own `useRef`. The cast it used typed `useRef<Element>(null)` as `{ current: Element }`, dropping the `null` that React and the upstream React Aria source rely on. `export * from 'octane'` now supplies `useRef`, with the same runtime function. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 29, 2026 13:35
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | ba31102 | Commit Preview URL Branch Preview URL |
Oct 29 2026, 01:37 PM |
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations
All 20 timed operations (19 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)No changes across 111 measured values. Public-import reachability bundles (bytes)No changes across 141 measured values. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | ba31102 | Commit Preview URL Branch Preview URL |
Oct 29 2026, 01:38 PM |
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
useRefcast inpackages/aria/src/compat/react.ts.export * from 'octane'now suppliesuseRef, and the compatReactdefault object takes it fromOctanelike every other hook.Why
useRef<Element>(null). fix: type useRef<T>(null) and useRef<T>(undefined) like React 19 #2281 added React 19'suseRef<T>(initial: T | null): { current: T | null }and(initial: T | undefined)overloads, so that is no longer true.Octane.useRef as <T>(initial: T | null) => { current: T }typeduseRef<HTMLButtonElement>(null)as{ current: HTMLButtonElement }. That drops thenullthat React's types and the upstream React Aria source rely on.Changes
useReffrom theObject.assignthat builds the compatReactobject.Octane.useReffunction. Compiled output for aria's call sites is unchanged too, because the compiler classifies auseRefimported fromcompat/reactby that import, not by howcompat/reactdefines it.useRef<X>(null)sites, whosecurrentis nowX | null. Six untypeduseRef(null)sites now infer{ current: null }, as React 19 does. The 25useRef<X | null>(null)sites were already nullable.compat/reactisn't in aria'sexportsmap, none ofindex.ts,statelyorcomponentsre-export it, and the only hook among the 11 changed sites (useAutoScroll) declares its return type. So there's no changeset.packages/aria/audit/pins no hash ofcompat/react.ts, so no audit update.Validation
pnpm format:check(not run repo-wide;pnpm format:files:check packages/aria/src/compat/react.tspasses)pnpm typecheck(not run repo-wide)pnpm test(not run locally; left to CI)pnpm exec octane-tsc -p packages/aria/tsconfig.json: 0 errors across 1,621 files with the cast removed. None of the ported React Aria source needed changes or!assertions.pnpm sync: no generated changesperf-review: not applicable. Types-only change to a binding's compat module. No runtime, compiler, or hot-path code changes, and the runtime function is identical.concise-code: src +1 −6 (runtime +0 −0); no new files or exports. Alternative considered: keep the wrapper and widen its return type to{ current: T | null }(one line). Rejected because it would duplicate the overloadsoctanenow declares. Bytes: not applicable.Risk / follow-ups
octanepeer stays^0.16.0, asoctanePeerRangeForsets for bindings. A consumer who typechecks aria's source againstoctane0.16.0–0.16.3, which lack fix: type useRef<T>(null) and useRef<T>(undefined) like React 19 #2281's overloads, will see TS2345 at the bareuseRef<X>(null)sites. fix: type useRef<T>(null) and useRef<T>(undefined) like React 19 #2281's octane changeset and this change ship in the same release, and peer floors follow the minor line by policy, so I didn't raise the floor. It also can't be raised before the new octane version is published.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Note
Low Risk
Types-only change to an internal compat module with identical runtime; consumers typechecking against pre-#2281 Octane may see new TS errors at bare
useRef<X>(null)sites.Overview
Removes the compat-layer
useRefwrapper inpackages/aria/src/compat/react.tssouseRefis re-exported from Octane viaexport * from 'octane', matching React 19's nullable ref typing after Octane #2281.The deleted cast incorrectly typed
useRef<X>(null)as{ current: X }(droppingnull); call sites now get{ current: X | null }where that matters. The defaultReactcompat object no longer overridesuseRef—onlyforwardRefis layered on. Runtime behavior is unchanged (sameOctane.useReffunction).Reviewed by Cursor Bugbot for commit ba31102. Bugbot is set up for automated code reviews on this repo. Configure here.