Skip to content

Commit

Permalink
handle corner case with bad props in simple component
Browse files Browse the repository at this point in the history
  • Loading branch information
Morglod committed Jul 12, 2024
1 parent 4dd2557 commit 67cfefe
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions build_examples/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ function SimpleVirtualListV(props) {
itemHeight: props.itemHeight,
renderItem: (itemIndex, topOffset) => {
const item = props.items[itemIndex];
if (!item)
return null;
return ((0, jsx_runtime_1.jsx)("div", { style: { position: 'absolute', top: `${topOffset}px` }, children: props.renderItem(item, itemIndex, topOffset) }, props.itemKey(item, itemIndex)));
}
}, [props.items, props.itemHeight]);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-virtual-overflow",
"version": "1.0.2",
"version": "1.0.3",
"description": "virtual scroll without headache",
"main": "lib/index.cjs.js",
"module": "lib/index.esm.js",
Expand Down
1 change: 1 addition & 0 deletions src/simple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function SimpleVirtualListV<ItemT>(props: SimpleVirtualListVProps<ItemT>)
itemHeight: props.itemHeight,
renderItem: (itemIndex: number, topOffset: number) => {
const item = props.items[itemIndex];
if (!item) return null;
return (
<div style={{ position: 'absolute', top: `${topOffset}px` }} key={props.itemKey(item, itemIndex)}>
{props.renderItem(item, itemIndex, topOffset)}
Expand Down

0 comments on commit 67cfefe

Please sign in to comment.