From eaf35c9bf5c4cc9ee9d98b39a2e63cfcd47625fa Mon Sep 17 00:00:00 2001 From: Welly Shen Date: Mon, 31 May 2021 01:35:15 +0800 Subject: [PATCH] perf: limit the cache number of resize observer with the length of items --- .changeset/twelve-roses-notice.md | 5 +++++ src/useVirtual.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/twelve-roses-notice.md diff --git a/.changeset/twelve-roses-notice.md b/.changeset/twelve-roses-notice.md new file mode 100644 index 00000000..3077527e --- /dev/null +++ b/.changeset/twelve-roses-notice.md @@ -0,0 +1,5 @@ +--- +"react-cool-virtual": patch +--- + +perf: limit the cache number of resize observers with the length of items diff --git a/src/useVirtual.ts b/src/useVirtual.ts index 10c2605f..f40bfe1b 100644 --- a/src/useVirtual.ts +++ b/src/useVirtual.ts @@ -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]);