ScrollableList: add code to debug error from Sentry

virtuoso-debug
Alex Gleason 2022-06-27 10:16:58 -05:00
rodzic b96148c9a4
commit 14befa8d19
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 11 dodań i 0 usunięć

Wyświetl plik

@ -214,6 +214,16 @@ const ScrollableList = React.forwardRef<VirtuosoHandle, IScrollableList>(({
return 0;
}, [showLoading, initialTopMostItemIndex]);
// Debugging Virtuoso!
// https://github.com/petyosi/react-virtuoso/issues/687#issuecomment-1160676080
const customCorrectItemSize = (el: HTMLElement, dimension: 'height' | 'width') => {
try {
return Math.round(el.getBoundingClientRect()[dimension]);
} catch (e) {
throw new Error(`${el} does not have getBoundingClientRect`);
}
};
/** Render the actual Virtuoso list. */
const renderFeed = (): JSX.Element => (
<Virtuoso
@ -241,6 +251,7 @@ const ScrollableList = React.forwardRef<VirtuosoHandle, IScrollableList>(({
Item,
Footer: loadMore,
}}
itemSize={customCorrectItemSize}
/>
);