📚 Had to post this a lot on the other platform lately and apparently, it blows people's mind that this is possible. I wrote it over 2 years ago, and callback refs will only get better in v19 because they will get cleanup functions. Have a read: tkdodo.eu/blog/avoidin...
Avoiding useEffect with callback refs
Interacting with DOM nodes doesn't necessarily need useEffect
tkdodo.eu