Skip to content
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

Blank space when scrolling to fast with TabFlashList #11

Open
mduc-dev opened this issue May 18, 2023 · 13 comments
Open

Blank space when scrolling to fast with TabFlashList #11

mduc-dev opened this issue May 18, 2023 · 13 comments

Comments

@mduc-dev
Copy link

mduc-dev commented May 18, 2023

When using TabFlashList scrolling fast there will be blank space problem of FlashList, do you know how to fix this?. I have switched to TabFlatList but android works fine and ios fails in first time open app.

blank.space_android.webm
blank_space_ios.mp4
@mduc-dev
Copy link
Author

@alantoa
Copy link
Contributor

alantoa commented May 18, 2023

hey@ducnguyen4301 can you provide an example on https://snack.expo.dev/?

@mduc-dev
Copy link
Author

Hi @alantoa, here is example for this https://snack.expo.dev/@ducnguyen4301/example-tab-flashlist. You can try it !

@alantoa
Copy link
Contributor

alantoa commented May 18, 2023

@ducnguyen4301 you are using Reanimated v3, right?

@alantoa
Copy link
Contributor

alantoa commented May 18, 2023

@ducnguyen4301 try this latest version that i just released it

@mduc-dev
Copy link
Author

Screenshot 2023-05-18 at 16 37 57

no im just use Reanimated v2

@alantoa
Copy link
Contributor

alantoa commented May 18, 2023

Have you tried to latest version that i just related?

@mduc-dev
Copy link
Author

@alantoa yes, i tried but problem still

@alantoa
Copy link
Contributor

alantoa commented Jun 2, 2023

@ducnguyen4301 hey, I think I understand your problem, you should make sure you are passing the correct index to your TabFlashList

@mduc-dev
Copy link
Author

mduc-dev commented Jun 3, 2023

Hi @alantoa , i don't think problem in my index, this appear blank space from flash list when i scrolling and change tab to fast

@Fengweiyuu
Copy link

hello,i resolve thie problem,you can try it:
set "getItemType"

<TabFlashList
  index={tabIndex}
  data={items}
  estimatedItemSize={120}
  scrollEventThrottle={16}
  keyExtractor={(item, index) => `${item.articleId}_${index}`}
  renderItem={({ item, index }) => (
    <ArticleView
      key={`${item.articleId}_${index}`}
      style={styles.item}
      nowTime={nowTime}
      article={item}
      hideAvatarRow={true}
      onArticleContentPress={article => handleArticleItemPress({ navigation, article })}
    />
  )}
  getItemType={(item, index) => `${item.articleId}_${index}`}
  ItemSeparatorComponent={() => <Divider size="hair" wingHorizontal={dimensions.h} />}
  ListFooterComponent={footerView}
  onEndReached={onEndReached}
/>

@hirbod
Copy link
Contributor

hirbod commented Jun 5, 2023

Hey, I have noticed an issue in your workaround. The getItemType method registers a new recycling pool for every single item. This approach is incorrect and can lead to crashes, especially with long lists. It should only be used to differentiate different item types (which vary significant in layout / dimensions)

The purpose of getItemType is to handle different layouts, like headlines, sections, or specific item types that differ from the one being recycled. This helps reduce the need for re-layout tasks. However, in your current implementation, you're registering a new pool for every item, which is not the right approach, totally disabled recycling and will skyrocket your memory. Correct behavior is to have a minimal set as possible (like 3-10 max, depending on the variation of your items).

So we need to fix this differently. Please revoke your changes. Your list consists of single item types, you don't need getItemType

@Fengweiyuu
Copy link

So we need to fix this differently. Please revoke your changes. Your list consists of single item types, you don't need getItemType

ok,i get it, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants