-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the issue
TargetCursor component tries to acces window during server-side rendering (SSR). But window is undefined during SSR.
⨯ ReferenceError: window is not defined
at <unknown> (src\components\TargetCursor.tsx:32:46)
at TargetCursor (src\components\TargetCursor.tsx:31:27)
30 |
31 | const isMobile = useMemo(() => {
> 32 | const hasTouchScreen = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
| ^
33 | const isSmallScreen = window.innerWidth <= 768;
34 | const userAgent = navigator.userAgent || navigator.vendor || (window as any).opera;
35 | const mobileRegex = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i; {
digest: '2667539285'
}
GET / 500 in 2.3s (compile: 1453ms, render: 831ms)Reproduction Link
No response
Steps to reproduce
-
Initialize and Add:
npx create-next-app@latestnpx shadcn@latest add @react-bits/TargetCursor-TS-TW
-
Update TargetCursor.tsx:
Since React Bits components often use hooks likeuseEffect, you must add the client directive:+ "use client"; import React, { useEffect, useRef, useCallback, useMemo } from 'react'; import { gsap } from 'gsap';
Validations
- I have checked other issues to see if my issue was already reported or addressed
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working