Comment
Comment by sswu
The TypeScript example does feel a little weird. I've used this library successfully with React + TypeScript with the following pattern:
As others have mentioned, the ref will typically attach by the time a `useEffect` hook is called, but for safety it's nice to have the null check.