Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update use-scroll.ts

Tim Wilson29f24980def2
diff --git a/packages/ui/src/hooks/use-scroll.ts b/packages/ui/src/hooks/use-scroll.ts
index 58377b9b03..ffab03eed2 100644
--- a/packages/ui/src/hooks/use-scroll.ts
+++ b/packages/ui/src/hooks/use-scroll.ts
@@ -1,7 +1,9 @@
import { useCallback, useEffect, useState } from "react";
export function useScroll(threshold: number) {
- const [scrolled, setScrolled] = useState(window.scrollY > threshold);
+ const [scrolled, setScrolled] = useState(
+ typeof window !== "undefined" ? window.scrollY > threshold : false,
+ );
const onScroll = useCallback(() => {
setScrolled(window.scrollY > threshold);