diff --git a/packages/react/src/WhenVisible.ts b/packages/react/src/WhenVisible.ts index 2dea97ef7..b2c6157e3 100644 --- a/packages/react/src/WhenVisible.ts +++ b/packages/react/src/WhenVisible.ts @@ -17,7 +17,7 @@ const WhenVisible = ({ children, data, params, buffer, as, always, fallback }: W fallback = fallback ?? null const [loaded, setLoaded] = useState(false) - const fetchedOnce = useRef(false) + const fetchedOnceRef = useRef(false) const fetchingRef = useRef(false) const ref = useRef(null) @@ -46,7 +46,7 @@ const WhenVisible = ({ children, data, params, buffer, as, always, fallback }: W return } - if (!always && fetchedOnce) { + if (!always && fetchedOnceRef.current) { observer.disconnect() } @@ -54,7 +54,7 @@ const WhenVisible = ({ children, data, params, buffer, as, always, fallback }: W return } - fetchedOnce.current = true + fetchedOnceRef.current = true fetchingRef.current = true const reloadParams = getReloadParams()