you can simply use the correct types to avoid the typescript errors.
const overlayEl = useRef<HTMLButtonElement | null>(null);