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 screen when scrolling fast #716

Open
shop-fluencer opened this issue May 25, 2022 · 2 comments
Open

Blank screen when scrolling fast #716

shop-fluencer opened this issue May 25, 2022 · 2 comments

Comments

@shop-fluencer
Copy link

Hello,

WhatsApp.Video.2022-05-25.at.22.41.27.mp4

Why I get blank screen when scrolling fast ?

Code:
Main

const RecyclerlistView = () => {
  const [ss, setSS] = useState(true);
  const [datas, setDatas] = useState(productListWithCategoryMock);

  const handleEnd = () => {
    console.log('S')
    setDatas(prev => [...prev, ...productListWithCategoryMock2]);
  };

  const data = React.useMemo(() => {
    return new DataProvider((r1, r2) => {
      return r1 !== r2;
    }, index => {
      return 'index' + index;
    });
  }, []);

  const dataprovider = React.useMemo(() => {
    return data.cloneWithRows(datas);
  }, [data, datas]);

  const layoutProvider = new LayoutProvider((i) => {
    return dataprovider.getDataForIndex(i).type;
  }, (type, dim) => {
    switch(type) {
      case 'CATEGORY':
        dim.height = 50;
        dim.width = width;
      break;
      case 'PRODUCT':
        dim.height = 235;
        dim.width = width / 2 - 0.0005
      break;
      default:
        dim.height = 0;
        dim.width = 0;
      break;
    }
  });

  const handlePress = () => {
    VibrateLight();
    setSS(!ss);
  };

  const rowRenderer = (type: any, data: any) => {
    return <MemoList type={type} data={data} />
  };

  return (
    <View style={{flex: 1}}>
      { datas.length > 0 &&
      <RecyclerListView 
        dataProvider={dataprovider}
        layoutProvider={layoutProvider}
        rowRenderer={rowRenderer}
        style={{flex: 1}}
        onEndReached={handleEnd}
        scrollViewProps={{showsVerticalScrollIndicator: false}}
      />
      }
    </View>
  )
}

Memo List

const Item2 = memo(({ name }: IRlvRenderProductProps) => (
  <Text style={s.category_title}>{ name }</Text>
), isEqual2)

const Item = memo(({ id, name, price, photos, onLongPress }: IRlvRenderProductProps) => (
  console.log(Math.random()),
  <Pressable onPress={() => onLongPress({ id, name })} delayLongPress={80} style={{padding: 8, paddingVertical: 12, justifyContent: 'center', alignItems: 'center', backgroundColor: '#fff', borderRadius: 8, margin: 10}}>
    <ImageSlider photos={photos} />
    <Text style={s.name} numberOfLines={1}>{ name }</Text>
    <Text style={s.price}>{price}€</Text>
  </Pressable>
), isEqual)

const MemoList = ({ type, data }: ) => {
  if(type === 'CATEGORY') {
    const { name } = data.item;
    return (
      <Item2
       name={name}
      />
    )
  } else {
    const { id, photos, name, price } = data.item;
  return (
    <Item
      id={id}
      name={name}
      photos={photos}
      price={price}
    />
  )
  }
}
@siddharth-kt
Copy link

Try updating yout renderAheadOffset prop on recyclerListView to 1000 or 2000.

@rassemdev
Copy link

renderAheadOffset

Although It fixes the problem, but i think it is a bug. What if some list exceeded 2000 pixel! Then it will show blank again.

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

3 participants