Skip to content

Commit 67cfefe

Browse files
committed
handle corner case with bad props in simple component
1 parent 4dd2557 commit 67cfefe

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

build_examples/demo.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ function SimpleVirtualListV(props) {
170170
itemHeight: props.itemHeight,
171171
renderItem: (itemIndex, topOffset) => {
172172
const item = props.items[itemIndex];
173+
if (!item)
174+
return null;
173175
return ((0, jsx_runtime_1.jsx)("div", { style: { position: 'absolute', top: `${topOffset}px` }, children: props.renderItem(item, itemIndex, topOffset) }, props.itemKey(item, itemIndex)));
174176
}
175177
}, [props.items, props.itemHeight]);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-virtual-overflow",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "virtual scroll without headache",
55
"main": "lib/index.cjs.js",
66
"module": "lib/index.esm.js",

src/simple.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export function SimpleVirtualListV<ItemT>(props: SimpleVirtualListVProps<ItemT>)
1919
itemHeight: props.itemHeight,
2020
renderItem: (itemIndex: number, topOffset: number) => {
2121
const item = props.items[itemIndex];
22+
if (!item) return null;
2223
return (
2324
<div style={{ position: 'absolute', top: `${topOffset}px` }} key={props.itemKey(item, itemIndex)}>
2425
{props.renderItem(item, itemIndex, topOffset)}

0 commit comments

Comments
 (0)