React-window: Grid columnWidth not called on rerender

Created on 7 Mar 2020  路  1Comment  路  Source: bvaughn/react-window

Trying to implement resizable columns with following example:
https://codesandbox.io/s/j30k46l7xw

And the problem is that columnWidth function get called on initial rendering only.
Is there a way to resize columns after Grid has been rendered?

Most helpful comment

Column width is cached for performance reasons unless the function prop changes.

You should call resetAfterColumnIndex if you want to invalidate size for a particular row or column. 鈽猴笍

From the docs:

resetAfterColumnIndex(index: number, shouldForceUpdate: boolean = true): void

VariableSizeGrid caches offsets and measurements for each column index for performance purposes. This method clears that cached data for all columns after (and including) the specified index. It should be called whenever a column's width changes. (Note that this is not a typical occurrance.)

By default the grid will automatically re-render after the index is reset. If you would like to delay this re-render until e.g. a state update has completed in the parent component, specify a value off false for the second, optional parameter.

>All comments

Column width is cached for performance reasons unless the function prop changes.

You should call resetAfterColumnIndex if you want to invalidate size for a particular row or column. 鈽猴笍

From the docs:

resetAfterColumnIndex(index: number, shouldForceUpdate: boolean = true): void

VariableSizeGrid caches offsets and measurements for each column index for performance purposes. This method clears that cached data for all columns after (and including) the specified index. It should be called whenever a column's width changes. (Note that this is not a typical occurrance.)

By default the grid will automatically re-render after the index is reset. If you would like to delay this re-render until e.g. a state update has completed in the parent component, specify a value off false for the second, optional parameter.

Was this page helpful?
0 / 5 - 0 ratings