React-window: Scrolling is spastic

Created on 16 Jun 2019  路  3Comments  路  Source: bvaughn/react-window

I landed on this library from Material-UI's documentation on Lists. I'm trying to implement a simple example of the FixedSizeList, but the scrolling goes crazy on me. When I try to scroll down the list, it jumps up and down and I repeatedly get onScroll backward/forward events.

What am I doing wrong here?

<FixedSizeList
    direction="vertical"
    itemData={availableLanguages} // array of objects
    height={300}
    width={'100%'}
    itemSize={30} // I think this is irrelevant with ListItem?
    itemCount={availableLanguages.length}
    onScroll={this.handleOnScroll} // added this just to debug what was going on
>
{({ index, data }) => (
    <ListItem key={index} dense button divider={index < data.length}>
        <ListItemText
            primary={data[index].description}
            secondary={data[index].abbreviation}
        />
    </ListItem> 
)}
</FixedSizeList>
馃憖 needs info

Most helpful comment

Doesn't look like you're using the style prop. That's very important.

If that doesn't turn out to be it, give me a runnable repro and I'll take a look. Otherwise, I've learned that it's not a great use of my time to guess from partial code examples.

All 3 comments

Doesn't look like you're using the style prop. That's very important.

If that doesn't turn out to be it, give me a runnable repro and I'll take a look. Otherwise, I've learned that it's not a great use of my time to guess from partial code examples.

I would also advise against using an inline function like that for the cell renderer.

Adding style={style} fixed my scrolling issue. Thank you.

I was just trying to get this to work in the simplest way possible. I'll be refactoring the guts of it now.

Was this page helpful?
0 / 5 - 0 ratings