-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Multiple call to render item #478
Comments
I have experienced this behavior as well. Here is a snack that reproduces this issue with static data. |
@deepakaggarwal7 @kdrich Does the problem still occur if you simply replace
|
RenderItem with a FlatList gets called once only for every iterated item. |
Same issue |
Ran into this issue as well. The fix is to make your key extractor more unique by combine your item key with the index. So something like |
@ethantran, it does look like keyExtractor is passed through to the Carousel component, though I don't see any change in behavior adding a more specific keyExtractor similar to what you reference above. You can see an example here The logs cumulate the total number of times each item is rendered. It is still three. |
I see. The keyExtractor fixed problem 2, the warning message, for me. I am not sure how to fix the multi-render except using a pure component. Example |
I have a similar problem. The renderItem gets triggered multiple times for the same index. It also triggers the renderItem with index 0 up to four times - no idea why this is happening
Even with initialNumToRender={1} and maxToRenderPerBatch={1} it still triggers renderItem 12 times. This is causing big performance issues for me. Any ideas? |
Any progress here? I get the same problem. |
any update here? |
same problem here. hint to get rid out of this issue change |
Any idea how to solve this ? @seniordev32 solution doesn't work |
For me, works with theses steps:
For API request, you must use:
|
Any update on this issues ? |
Are you changing state in renderItem? |
I'm changing state in onSnapToItem (to save the current item) but this rerenders the carousel which in turn jumps back to the index specified in firstItem. Any solution to this? |
Couple of points:
|
Any update on this issues ? |
Same issue, any solution ? |
Try using a pure component. Here is a barebones example, you can abstract the pure component to it's own file
|
@ebarahona Yes, my item is a PureComponent, but the render is call many |
I moved whole renderItem function to the new PureComponent (I use functional components, so I use React.memo) import React from "react";
export default React.memo(() =>
const daysToRender = [0, 1, 2, 3]
return(
<Carousel data={daysToRender} renderItem={
(props) => <ScrollPaneView item={props.item} index={props.index}/>
)) ScrollPaneView.js:export default React.memo(({item, index} => {
console.log("Rendering", index)
return (
<View><Text>Rendered</Text></View>
)
} And now renderItem is called only once for each item. |
Memory leak after memoizing? Are you using this on a more complex real-world use case? My render-item is a video component with a lot of metadata and nested child components |
According to React docks, |
Hi @ebarahona , if you found an optimal solution for video content. can you please share with us. I'm also facing some issues while rendering video content with snap-carousal. |
I have a working "solution" not an elegant one but it's currently working. I can provide you with some help, reach out via email, same username at gmail |
It's a questiob but may turn out to be a bug.
Problem:
_renderItems
gets called thriceHow to replicate:
Following is the code to display a carousel in a very simple example:
There are 2 problems:
RenderItems is getting called thrice
Image
I see a virtualized key warning message despite official docs mentioning that explicit key isn't required to be specified
Image
The text was updated successfully, but these errors were encountered: