I noticed this practice. Is it okay to do so? Provided that you need a variable that will hold the value and not lose it when rendering. What other hacks/tricks are similar to this one?
OK, this is explicitly stated in the documentation :
The useRef() Hook isn't just for DOM refs. The “ref” object is a generic container whose current property is mutable and can hold any value, similar to an instance property on a class.