diff --git a/src/HomePage.tsx b/src/HomePage.tsx index 677b2e5..411e0e4 100644 --- a/src/HomePage.tsx +++ b/src/HomePage.tsx @@ -13,8 +13,8 @@ import "./App.css"; export default function Homepage() { const navigate = useNavigate(); - const dialogRef = useRef(null); - const blockbusterButtonRef = useRef(null); + const dialogRef = useRef(null); + const blockbusterButtonRef = useRef(null); const isTouchDevice = () => "ontouchstart" in window || navigator.maxTouchPoints > 0; @@ -28,11 +28,12 @@ export default function Homepage() { const [showDeclineQ, setShowDeclineQ] = useState(false); const openPopup = () => { - dialogRef.current.showModal(); + dialogRef.current?.showModal(); // Wait for layout to settle requestAnimationFrame(() => { const button = blockbusterButtonRef.current; + if (!button) return; const rect = button.getBoundingClientRect(); button.style.left = `${rect.left}px`; @@ -45,6 +46,7 @@ export default function Homepage() { * ------------------------------------------------------------------ */ const moveButton = () => { const button = blockbusterButtonRef.current; + if (!button) return; const buttonRect = button.getBoundingClientRect(); @@ -61,7 +63,7 @@ export default function Homepage() { }; - const handleRunawayPress = (event) => { + const handleRunawayPress = (event: React.MouseEvent | React.TouchEvent) => { if (isTouchDevice()) { event.preventDefault(); event.stopPropagation();