-
Notifications
You must be signed in to change notification settings - Fork 577
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
useQuery data cannot be used directly in FlatList #5404
Comments
I cannot see what the type of Using the spread operator ( |
._id is a BSON ObjectId Using .toHexString() makes no difference. |
Same problem. The _id is Unique for every item |
I think I found the issue, the react-native FlatList component _getItemCount looks like this:
Array.isArray(tasklists) is returning false. The object returned from useQuery fails Array.isArray(), so _getItemCount is returning 0. |
When i see the typo of the useQuery, ir gives me object |
That’s correct, and an array is an object.. But Array.isArray(useQueryResponseObject) is false. The object looks like an array, but it isn’t passing the isArray test. I believe isArray looks for the existence of a .toString() method on the object but I could be wrong there. |
Here is the react-native FlatList commit that breaks the useQuery hook: |
The workaround I’m currently using is patch-package to revert the Array.isArray() guard.
Moving forward, though, it seems that Realm.Results needs to be updated to pass the data guard inserted with react native 0.71. |
Looks like this was added in |
Just an update. We are currently in discussions with Meta on how to proceed with this matter. We have two options, either they include a way that we can bypass their check, or we create a Proxy object that wraps an Array and access a Realm collection (with a possible performance regression). |
Could a third option be to export a FlatList component from the @realm/react package that reverts their check? Then users could import {FlatList} from ‘@realm/react’ instead of from ‘react-native’. |
@skam22 while possible, I would rather we obtain compatibility with React Native primitives. In any case, we are directly in contact with Meta at this time and hopefully will have a resolution soon. |
Any updates on this issue? First option seems reasonable because Realm is widely used in React Native. |
@hadnet Nothing to report right now, we are still in discussions. That being said, it is a priority for us to resolve this, so we will post as soon as we have an update. |
After discussing this with Meta, they have agreed to loosen the restrictions on the |
The following PRs to Once these are live, we can close this. Thanks everyone for your patience. |
Another update. React Native 0.71.4 is being put together and will fix the issue. Hopefully will happen soon! |
Same issue after upgrade to 0.71.3
|
New version is disponible: https://react-native-community.github.io/upgrade-helper/?from=0.71.3&to=0.71.4 Upgrade solve me. |
React Native 0.71.4 is out! If you want |
tested with flatlist and sectionList. Works excelent!! |
React native 0.71.3 doesn’t include the changes that meta added. Upgrade to at least 0.71.4
On Jun 22, 2023, at 11:13 AM, lufke wrote:
The problem is back again for FlatList, just created an react native app and must use spread operator on data for see the items on list, otherwise it shows an empty list
“react": "^0.5.0"
"react-native": "0.71.3"
"realm": "^11.10.1"
I can see the items on console.log
|
I deleted the coment because when paste the dependencies i Saw tjat i was using rn 0.71.3 instead 0.71.4 |
How frequently does the bug occur?
Always
Description
this returns an empty FlatList:
memoizing the useQuery response also returns an empty FlatList:
spreading the useQuery response to a new array correctly displays the items in the list:
mapping through the useQuery response renders correctly as well (but without the benefit of the virtualized list).
the same source code works fine if pasted into the template starter (react-native.todo.flex) which installs react-native 0.70.5, @realm/react 0.4.1, realm 11.2.0
Stacktrace & log output
No response
Can you reproduce the bug?
Always
Reproduction Steps
No response
Version
realm 11.4.0, @realm/react 0.4.3, react-native 0.71.2
What services are you using?
Atlas Device Sync
Are you using encryption?
Yes
Platform OS and version(s)
IOS and Android
Build environment
realm 11.4.0, @realm/react 0.4.3, react-native 0.71.2
Cocoapods version
No response
The text was updated successfully, but these errors were encountered: