Skip to content

Commit

Permalink
perf: limit the cache number of resize observer with the length of items
Browse files Browse the repository at this point in the history
  • Loading branch information
wellyshen committed May 30, 2021
1 parent 958b751 commit eaf35c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/twelve-roses-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-cool-virtual": patch
---

perf: limit the cache number of resize observers with the length of items
2 changes: 1 addition & 1 deletion src/useVirtual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export default <
isScrollToItemRef.current = false;
userScrollRef.current = true;

const len = rosRef.current.size - msDataRef.current.length;
const len = rosRef.current.size - items.length;
const iter = rosRef.current[Symbol.iterator]();
for (let i = 0; i < len; i += 1)
rosRef.current.delete(iter.next().value[0]);
Expand Down

0 comments on commit eaf35c9

Please sign in to comment.