Skip to content

Commit c7032ad

Browse files
kakadiadarpanClaudéric Demers
authored and
Claudéric Demers
committed
Updated README with information on how to trigger re-render for sorted data. (#35)
1 parent 548ba5a commit c7032ad

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ This method force recomputes the item sizes after the specified index (these are
9696
`VirtualList` has no way of knowing when its underlying data has changed, since it only receives a itemSize property. If the itemSize is a `number`, this isn't an issue, as it can compare before and after values and automatically call `recomputeSizes` internally.
9797
However, if you're passing a function to `itemSize`, that type of comparison is error prone. In that event, you'll need to call `recomputeSizes` manually to inform the `VirtualList` that the size of its items has changed.
9898

99+
### Common Issues with PureComponent
100+
`react-tiny-virtual-list` uses [PureComponent](https://reactjs.org/docs/react-api.html#reactpurecomponent), so it only updates when it's props change. Therefore, if only the order of your data changes (eg ['a','b','c'] => ['d','e','f']), `react-tiny-virtual-list` has no way to know your data has changed and that it needs to re-render.
101+
102+
You can force it to re-render by calling [forceUpdate](https://reactjs.org/docs/react-component.html#forceupdate) on it or by passing it an extra prop that will change every time your data changes.
103+
99104
## Reporting Issues
100105
Found an issue? Please [report it](https://github.com/clauderic/react-tiny-virtual-list/issues) along with any relevant details to reproduce it. If you can, please provide a live demo replicating the issue you're describing. You can [fork this Code Sandbox](https://codesandbox.io/s/kymm7z9qr) as a starting point.
101106

0 commit comments

Comments
 (0)