Usually when I use React + Typescript and I have to work with refs I usually use this check:
const ref = useRef(null) ... if(ref &&