bvaughn / react-window

React components for efficiently rendering large lists and tabular data
https://react-window.now.sh/
MIT License
15.48k stars 778 forks source link

VariableSizeGrid innerElementType recieves NaN in width/height after resetAfterIndex with a NaN index #724

Open nking07049925 opened 1 year ago

nking07049925 commented 1 year ago

Recently run into an issue with a console warning

Warning: `NaN` is an invalid value for the `width` css style property.

There was a mistake in our code, where resetAfterColumnIndex was being called with the index value of NaN. Which resulted in lastMeasuredColumnIndex being set to NaN, since the typeof index === "number" check passes for NaN and it snowballs to style.width for the innerElementType also being computed as NaN.

https://github.com/bvaughn/react-window/blob/6ff5694ac810617515acf74401ba68fe2951133b/src/VariableSizeGrid.js#L448-L468

This is clearly incorrect api usage, but should there be some check for this or a separate warning, since the resulting react warning (the "style.width is NaN") is fairly misleading on the cause of the issue?