-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List State: collection.getItem()
can return undefined
#5776
Comments
Just to make sure, you are just using the hooks in your implementation right? No RAC components? I ask because RAC has a different collections setup than what we had before. Its hard for me to say what is occurring here without a reproduction I can dig into on my end, are you able to add breakpoints to find out what the collection and cached collection is? We could always add some more resiliency against the |
i have the same issue |
i think they need add |
Same problem on me, looks like overwriting package locally, and making all startItem variables optionally chained solves the issue. Not sure if owners of the package will accept that PR, but I can maybe fix that in my free time.
☝🏻 collection can be undefined when I spam on useAnycList items - set, delete, change quickly and the error is thrown. No issue when optionally chained |
Adding the optional chaining sounds good to me, but just to double check: where does focus land with the above change? Does it get lost to the document body? Or does it land on the list itself? |
Provide a general summary of the issue here
Well. I have a very hard to reproduce bug - it's randomly happening - and hard to check in the current repo the returned type. So, I build a Combobox thanks to the hooks and load async some data to fill the items - with or without useAsyncList btw - and sometimes I receive:
so looks like that here
react-spectrum/packages/@react-stately/list/src/useListState.ts
Line 63 in b5974ad
collection.getItem()
can returnundefined
🤔 Expected Behavior?
It doesn't crash ^_^
😯 Current Behavior
It does crash :-/
💁 Possible Solution
No response
🔦 Context
No response
🖥️ Steps to Reproduce
It's a very hard issue to reproduce and hard to have an easy example unfortunately.
I can't have a setup with the current reop that returns another type that "any", so it's really hard to find out what happens.
The only thing I know it that you need to:
as fast as you can to trigger it. I feel like checking the possible returned value of
getItem
would be easier but I was unsuccessful here.Version
latest
What browsers are you seeing the problem on?
Chrome
If other, please specify.
No response
What operating system are you using?
Windows
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response
The text was updated successfully, but these errors were encountered: