U
U
uRoot2021-02-24 18:29:48
React
uRoot, 2021-02-24 18:29:48

UseRef as a variable. This is fine?

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?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-02-24
@uroot

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.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question