🐛(components) resolve the calendar hooks to a single react-aria copy - #304
Open
NathanVss wants to merge 1 commit into
Open
🐛(components) resolve the calendar hooks to a single react-aria copy#304NathanVss wants to merge 1 commit into
NathanVss wants to merge 1 commit into
Conversation
useCalendarGrid came from the react-aria umbrella while useCalendarCell and useCalendar came from @react-aria/calendar. Those hooks exchange per-render state through a WeakMap held in module scope, so a consumer whose tree carries two copies of the package had the cell read a map the grid never wrote to, and every click on a date threw on a failed ariaLabel destructuring. This repository resolves a single copy, so the split could not surface here and no test could have caught it. A lint rule keeps the calendar and date picker hooks on their scoped packages instead.
NathanVss
force-pushed
the
fix/calendar-single-import
branch
from
September 4, 2026 16:00
59237b2 to
642cb24
Compare
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.
Problem
Calendarimports its three react-aria hooks through two different names:They exchange per-render state through
hookData, aWeakMapheld in module scope.That works only while every hook is the same module instance. In a consumer whose tree
carries two copies of
@react-aria/calendarthe grid writes to one map and the cellreads the other, so opening a date picker throws:
This repository resolves a single copy of everything, which is why the split is
invisible here — typecheck, unit tests, component tests and Storybook all pass with the
bug present. No test could have caught it, so the guard has to be static.
Drive hit this on the date filter after upgrading to 1.1.1.
Changes
CalendarGrid.tsximportsuseCalendarGridfrom@react-aria/calendar, so all thecalendar hooks resolve to one copy.
no-restricted-importsrule blocks the calendar and date picker hooks from beingimported through
react-aria/react-stately. Type imports stay allowed, sincetypes are erased and create no module instance.
The
@react-aria/*pins are deliberately left exact. Relaxing them to^is worse, notbetter:
^3.9.5resolves to@react-aria/calendar3.10.1, which is a re-export shimrequiring
react-aria^3.48.0, and that pulls a second umbrella in beside the pinned3.47.0 — 41 nested copies in a scratch install.
Verification
Built this branch and installed the result into Drive's
node_modules, leaving itsduplicated tree in place and removing the
resolutionsworkaround it currently needs:Reverting the lint rule's target line reproduces the original import and fails
eslint.