React-window: [VariableSizeList] How can I resize item after changing its height?

Created on 10 Oct 2019  路  1Comment  路  Source: bvaughn/react-window

I'm using VariableSizeList to render a long form, each form item is expandable. So I want to resize the item height after expand it. But the getItemSize method is called only once. How can I recall getItemSize after it has been called?

Most helpful comment

Check out the VariableSizeList docs? Specifically look at the resetAfterIndex method:

resetAfterIndex(index: number, shouldForceUpdate: boolean = true): void
VariableSizeList caches offsets and measurements for each index for performance purposes. This method clears that cached data for all items after (and including) the specified index. It should be called whenever a item's size changes. (Note that this is not a typical occurrance.)

By default the list 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 offalsefor the second, optional parameter.

You'll want to call this method to reset the called size of an item after it expands or collapses.

>All comments

Check out the VariableSizeList docs? Specifically look at the resetAfterIndex method:

resetAfterIndex(index: number, shouldForceUpdate: boolean = true): void
VariableSizeList caches offsets and measurements for each index for performance purposes. This method clears that cached data for all items after (and including) the specified index. It should be called whenever a item's size changes. (Note that this is not a typical occurrance.)

By default the list 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 offalsefor the second, optional parameter.

You'll want to call this method to reset the called size of an item after it expands or collapses.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bitboxer picture bitboxer  路  3Comments

maynir picture maynir  路  4Comments

vinnymac picture vinnymac  路  3Comments

jsu93 picture jsu93  路  4Comments

gonuit picture gonuit  路  3Comments