From a92fd478a3c1891ac374ebe5e6c8b3c296327554 Mon Sep 17 00:00:00 2001 From: Matt Montag Date: Sun, 22 Sep 2024 16:05:57 -0700 Subject: [PATCH] Return early when state is null or undefined The strict equality check for state === undefined in setStateIfNeeded can cause a crash if state is null. --- src/VirtualList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VirtualList.js b/src/VirtualList.js index a2a74d5..81e1c02 100644 --- a/src/VirtualList.js +++ b/src/VirtualList.js @@ -53,7 +53,7 @@ const VirtualList = (options, mapVirtualToProps = defaultMapToVirtualProps) => ( // get first and lastItemIndex const state = getVisibleItemBounds(list, container, items, itemHeight, itemBuffer); - if (state === undefined) { return; } + if (state == null) { return; } if (state.firstItemIndex > state.lastItemIndex) { return; }