React-window: Scrolling issues if style is omitted

Created on 24 Jan 2019  路  6Comments  路  Source: bvaughn/react-window

Hi, it's my first time using react-window for a project of mine. You can see the current usage of it here.

I encountered an issue where my list would start stuttering and experiencing major scrolling issues which I assumed was related to some data being re-rendered or something along that line. Days of research and experimentation later, I discovered that the issue could be replicated even in one of your examples; the memoized list. If I simply remove style={style} from the Row, then upon scrolling you'll see the issues appear.

This seems to contradict the documentation which says

style: Object = null
Optional inline style to attach to outermost <div> element.

So my question is, what can be done to resolve this issue?

馃挰 question

Most helpful comment

If I simply remove style={style} from the Row

That would not be using the library correctly. It's required that you attach the style prop to whatever elements your item renderer returns, because that's how react-window positions them.

The docs entry you linked to about style is referencing an optional style that you can set _on the list itself_ (not the individual items). All of the docs examples should show correct usage of the style prop passed to the item (row) renderer.

Hope this clears things up!

All 6 comments

If I simply remove style={style} from the Row

That would not be using the library correctly. It's required that you attach the style prop to whatever elements your item renderer returns, because that's how react-window positions them.

The docs entry you linked to about style is referencing an optional style that you can set _on the list itself_ (not the individual items). All of the docs examples should show correct usage of the style prop passed to the item (row) renderer.

Hope this clears things up!

Oh now I understand, it would be nice if this was explicitly written in the docs somewhere. Thanks for the quick response and clarification!

That the style prop must be set really should be emphasized more in the docs. I just spent the last hour trying to fix this.
Thank you both for this issue btw.

How would you suggest emphasizing it beyond showing it being used in every documentation example?

screen shot 2019-02-19 at 8 45 07 am
screen shot 2019-02-19 at 8 45 16 am
screen shot 2019-02-19 at 8 45 24 am

I appreciate the feedback but there's only so much I can do here. I wrote a ton of documentation, examples, working Code Sandbox demos...

I think just a simple note stating that style is a required property for react-window to work would suffice. Looking at the examples won't necessarily tell a user that they need to include the style.

E.g. If they're just getting into testing it, maybe they want to see it without any style (especially if they didn't pass a style to it). That was my thinking at least, maybe others share a similar sentiment.

Took me a bit, but I added a section to the FAQs.

Was this page helpful?
0 / 5 - 0 ratings