by mlsarecmg · 5y ago · 0 comments
null! is a common typescript thing, it is a semantic guarantee that the ref is static and hence will be available. this saves you the if (ref.current) { ... } check.
const ref = useRef()
useEffect(() => console.log(ref), [])
return <div ref={ref} />
will return { current: [dom node] } const ref = useRef()
useEffect(() => console.log(ref), [])
return <mesh ref={ref} />
will return { current: [mesh node] }