DEV Community

Discussion on: Using refs to check if a component is still mounted.

Collapse
 
tusharkashyap63 profile image
Tushar Kashyap • Edited

I already answered this in a reply to another comment.

"I follow a general rule of using refs if I don't want to re-render, and using state if I want to re-render. I use local variables only for the derived state(incoming props). Also it was giving me a linting error as local variables value is lost on every re-render(which is fine in this case)."