DEV Community

Discussion on: useRef or useState, which is better?

Collapse
 
gyandeeps profile image
Gyandeep Singh • Edited

Mostly I use the rule, if state shows up on the UI than useState else useRef. That way you save up on unnecessary renders. Obviously there might be exceptions such as to if you want to trigger other hooks etc

Collapse
 
salehmubashar profile image
Saleh Mubashar

yup that is a very good approach!

Some comments have been hidden by the post's author - find out more