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?
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.
Most helpful comment
Check out the
VariableSizeListdocs? Specifically look at theresetAfterIndexmethod:You'll want to call this method to reset the called size of an item after it expands or collapses.