-
Notifications
You must be signed in to change notification settings - Fork 282
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
ViewableItems not working with FlashList #566
Comments
Hey @brunolcarlos 👋 Could you create a reproducible sample (either on GitHub or on expo's snack) and add steps how to reproduce the issue, detailing the exact specifics of what you are seeing? The code snippet you posted does not include the complete code. |
HI formarek, it's not a message error ou compiling error exactly. |
@brunolcarlos the incomplete code is making debugging this harder but if I have to guess, it's probably because FlashList doesn't update all the items unless your |
Hi, I don't need to update the array list, I only update the child when is on viewport and pass a prop to child with true or false. The Component Video doesn't receive this new information with the flashlist but receive with FlatList. |
@brunolcarlos I got that. Did you try updating |
Hi @naqvitalha , I'm not sure if you understood whats is happening. Using viewableItems I can get them
AND here I pass the information to my Video Component
ON this line
With FlashList its not working but with FlatList works how I expected With FlashList the rendered components do not receive from props the new state |
The issue with your solution is that the item does not re-render when |
I had a similar issue and tried this out by using extraData. but when it comes to updating any state I get an infinite rerender. Any suggestions on how I can perhaps overcome that? @brunolcarlos did you manage to find a solution? |
Nope, I moved back to FlatList. |
@chrisedington happy to help if you provide a sample |
I can tell you that Viewability works absolutely fine with FlashList. I am using it in production apps on huge lists. The issues I've came across have been the use of state inside my children and the way I've kept track of my refs. You need to make sure to react to changes within useEffect when using state in your items or use a smarter way, like context to react to visibility inside your items (starting/stopping videos is exactly what I am doing) I'd recommend you this Gist by @intergalacticspacehighway I've ported his approach to FlashList within 5 minutes and its actually the most performant way to react to visibility changes. |
With FlatList works, with FlashList not. |
As said, it does. You're doing something wrong and not sharing enough to really help |
No, It's not working.
I'm doing everything right, I have this feature on my app about 3 years and
wirh flashlist it's not working.
Only with FlatList.
Em dom., 11 de set. de 2022 11:03 AM, Hirbod ***@***.***>
escreveu:
… As said, it does. You're doing something wrong
—
Reply to this email directly, view it on GitHub
<#566 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADAWQWG6DFPD7URSGAQSVHTV5XRCBANCNFSM56WS4FGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Yes, because those lists you've been working with are not recycling. You need to understand that when you recycle views, you need to take care of some circumstances, like stale state (when you are working with state). If you wan't help, setup up a repro with Snack and I can help you out. |
I'm changing the state on every component and it's not working when you need change the state after the component is mounted. |
I'll give up. Have fun with FlatList. |
I'm closing this due to the lack of a sample that we can work with. If you do decide to create one please provide it and we'll look into it. |
I can tell you that My list re-renders fine. The item itself renders. The |
@naqvitalha this would explain the issue we once tried to bugfix (videos not firing play/stop when data changes) I was able to fix this issue though, at least for my app. We changed our |
Could you please provide your flashlist implementation for this gist? Thanks |
The problem its not if is firing or not, the problem is because the Component still static and nothing change. |
Hey @brunolcarlos , a colleague showed me this issue and I wanted to give you my input on the matter, and to anyone finding this issue. RPReplay_Final1697231525.mp4There are some key rules when developing short video feeds, here are the most important:
About "Viewable Items" events:
I hope this helps, I can't share much code but this should show how practical and simple that implementation can be. Viewable Config:Viewable Method(stored in zustand store):List Item Using that for autoplay: |
Some misconceptions here:
|
In case anyone needs help on this issue, there is a solution that worked for me. In my case, I was sending a prop and a callback to change its value to the item rendered in flashlist but I noticed that the value wouldn't change within the item, but it would in the component where I had the flashlist. So the solution was to trigger a re-render that would make sure the items of flashlist receive that change. Here is a short snippet:
Then go to your Flashlist component and add the re-render variable to extra data
This let me use the viewableItemsConfig and other stuff such as passing the flashlist ref to the items and using scrollToIndex method within the item to scroll to next post, and I imagine it can be done for clicking on buttons too then. |
We have a proper fix for this, Nishan will provide a PR for this next week. |
With FlatList and react-native-big-list the ViewableItems works fine but with FlashList does't works
When the items change the FlashList it's not passing the new state to Component inside of the renderItem
How can I fix It ?
This is a Android APP expo 46 and Expo GO
The text was updated successfully, but these errors were encountered: