react-component / react-component/virtual-list

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.

Open
#171 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
814
Forks
171
Avg merge
1h 3m
Merged PRs (30d)
3

Description

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>
  }

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the VirtualList entry point shown in the example and inspect how visible rows and dynamic item heights are handled. The issue names no file or test; done means exposing an overscanRowCount option and reducing flicker for chat messages whose heights depend on their content.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.