fix: recycling hooks crash when rendered outside of a LegendList - #498
Merged
jmeistrich merged 1 commit intoAug 8, 2026
Merged
Conversation
Daniel-Griffiths
force-pushed
the
fix/recycling-hooks-outside-list
branch
from
July 14, 2026 19:53
f2148e2 to
7fa34f8
Compare
jmeistrich
force-pushed
the
fix/recycling-hooks-outside-list
branch
from
August 8, 2026 00:19
7fa34f8 to
333ce86
Compare
Member
|
Thank you! |
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.
The bug
Since 3.3.2, calling
useRecyclingEffectoruseRecyclingStatein a component that is rendered outside of aLegendListthrows:This was a regression in 3.3.2's recycling-hooks rework ("Recycled rows update their current item without changing the container context"): the hooks now read the current item through
useArr$→createSelectorFunctionsArr, which dereferencesctx.valuesinpeek$without checking that theContextStateprovider exists. In 3.3.0 the hooks only touched the container context, which is null-safe, so shared item components (e.g. a swipeable row used both inside a list and in a plainScrollViewor modal) worked fine.Other hooks in
ContextContainer.tsalready treat this as a supported case ("Fail gracefully if used outside context"), so this restores that behavior for the signal-reading path.The fix
createSelectorFunctionsArrreturns a no-op selector (stable empty array, no-op subscribe) when there is no state context, anduseArr$/useSelector$drop their non-null assertions so the null flows through with correct types.useContainerItemInfoalready returnsundefinedwhen there's no container context, so the hooks no-op exactly as they did in 3.3.0.Tests
Added
__tests__/hooks/useRecyclingEffect.test.tsxcovering both hooks rendered outside a list — both fail with theTypeErrorbefore the fix and pass after. Full suite: 1468 pass, 1 pre-existing failure (LegendList.bootstrapInitialScroll.oldarch.test.ts, fails identically on cleanmainin my environment).biome checkclean.For the meantime this is the patch I am using to resolve this issue in my apps using 3.3.2