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

overscanRowCount - Number of rows to render above/below the visible bounds of the list. This can help reduce flickering during scrolling on certain browsers/devices. #171

Open
Valtas opened this issue Mar 14, 2022 · 0 comments

Comments

@Valtas
Copy link

Valtas commented Mar 14, 2022

I have a list of chat messages. The message height depends on the content.

My code is below. And everything seems to work well, but there is one moment, I can’t find the "overscanRowCount" property. Number of rows to render above/below the visible bounds of the list. This can help reduce flickering during scrolling on certain browsers/devices.

Can you do something about the flicker?

const Message = ({ i }: any, ref: any) => {
    return (
        <div
            ref={ref}
            style={{
                border: "1px solid gray",
            }}
        >
            <Avatar />
            message {i}
            // Dynamic height by content
            {i % 2 ? <div style={{ height: 100 }} /> : null}
        </div>
    );
};
const ForwardMessage = React.forwardRef(Message);

const Chat = () => {
      const listRef = React.useRef<any>(null);
      const size = useSize();
  
      // Infinite scroll
      const onScroll = (e: any) => {
          if (e.target.scrollHeight - e.target.scrollTop === size?.height) {
              appendData();
          }
      };
    
        <VirtualList
            ref={listRef}
            data={data}
            height={size?.height}
            itemHeight={30}
            itemKey="email"
            onScroll={onScroll}
        >
            {(item: any, i: any) => <ForwardMessage i={i} {...item} />}
        </VirtualList>
  }
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

1 participant