Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix auto-defined keys to avoid conflicts with user-defined keys #157

Merged
merged 1 commit into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions src/react/VList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,13 @@
if (!scrolling) {
onScrollStop[refKey] && onScrollStop[refKey]();
}
}, [scrolling]);

Check warning on line 260 in src/react/VList.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook useEffect has a missing dependency: 'onScrollStop'. Either include it or remove the dependency array

useEffect(() => {
if (!onRangeChangeProp) return;

onRangeChangeProp(startIndex, endIndex);
}, [startIndex, endIndex]);

Check warning on line 266 in src/react/VList.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook useEffect has a missing dependency: 'onRangeChangeProp'. Either include it or remove the dependency array. If 'onRangeChangeProp' changes too often, find the parent component that defines it and wrap that definition in useCallback

useImperativeHandle(
ref,
Expand All @@ -288,7 +288,7 @@
},
};
},
[]

Check warning on line 291 in src/react/VList.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook useImperativeHandle has missing dependencies: 'scroller' and 'store'. Either include them or remove the dependency array
);

const overscanedStartIndex = max(startIndex - overscan, 0);
Expand All @@ -296,25 +296,23 @@
const items = useMemo(() => {
const res: ReactElement[] = [];
for (let i = overscanedStartIndex; i <= overscanedEndIndex; i++) {
const e = elements[i];
// This can be undefined when items are removed
if (exists(e)) {
res.push(
<ListItem
key={(e as MayHaveKey).key || i}
_resizer={resizer}
_store={store}
_index={i}
_element={ItemElement as "div"}
_children={e}
_isHorizontal={isHorizontal}
_isRtl={isRtl}
/>
);
}
const e = elements[i]!;
const key = (e as MayHaveKey).key;
res.push(
<ListItem
key={exists(key) ? key : "_" + i}
_resizer={resizer}
_store={store}
_index={i}
_element={ItemElement as "div"}
_children={e}
_isHorizontal={isHorizontal}
_isRtl={isRtl}
/>
);
}
return res;
}, [elements, overscanedStartIndex, overscanedEndIndex]);

Check warning on line 315 in src/react/VList.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook useMemo has missing dependencies: 'ItemElement', 'isHorizontal', 'isRtl', 'resizer', and 'store'. Either include them or remove the dependency array

return (
<Viewport
Expand Down
30 changes: 14 additions & 16 deletions src/react/WVList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,22 +232,20 @@ export const WVList = forwardRef<WVListHandle, WVListProps>(
const items = useMemo(() => {
const res: ReactElement[] = [];
for (let i = overscanedStartIndex; i <= overscanedEndIndex; i++) {
const e = elements[i];
// This can be undefined when items are removed
if (exists(e)) {
res.push(
<ListItem
key={(e as MayHaveKey).key || i}
_resizer={resizer}
_store={store}
_index={i}
_element={ItemElement as "div"}
_children={e}
_isHorizontal={isHorizontal}
_isRtl={false}
/>
);
}
const e = elements[i]!;
const key = (e as MayHaveKey).key;
res.push(
<ListItem
key={exists(key) ? key : "_" + i}
_resizer={resizer}
_store={store}
_index={i}
_element={ItemElement as "div"}
_children={e}
_isHorizontal={isHorizontal}
_isRtl={false}
/>
);
}
return res;
}, [elements, overscanedStartIndex, overscanedEndIndex]);
Expand Down
Loading