News for hackers. Stuff that matters.
Re:Common Beginner Mistakes with React by phailhaus on Saturday March 11, 2023 @05:02PM (#35113241)
Of course you can! That's the whole point of refs, and why you can't use them as a dependency to callbacks or effects. They're totally mutable, which makes them very tricky to deal with. I mean, I wouldn't recommend updating them outside of effects/callbacks, but it's valid. For example: you can make a ref to count the number of times React calls your render loop by updating it in the body.

There are no comments on this comment yet.