fix(createVirtualizer): add window check to resolve the ReferenceError
This commit is contained in:
@@ -258,12 +258,13 @@ export function createVirtualizer<T>(
|
||||
// Calculate initial offset ONCE
|
||||
const getElementOffset = () => {
|
||||
const rect = node.getBoundingClientRect();
|
||||
return rect.top + window.scrollY;
|
||||
const scrollY = typeof window !== 'undefined' ? window.scrollY : 0;
|
||||
return rect.top + scrollY;
|
||||
};
|
||||
|
||||
let cachedOffsetTop = 0;
|
||||
let rafId: number | null = null;
|
||||
containerHeight = window.innerHeight;
|
||||
containerHeight = typeof window !== 'undefined' ? window.innerHeight : 0;
|
||||
|
||||
const handleScroll = () => {
|
||||
if (rafId !== null) {
|
||||
|
||||
Reference in New Issue
Block a user