How to work with refs properly and when are they needed?
Answer
•refs provide access to the DOM/instance.
•Needed for focus, measurements, integration with libraries.
•Do not use refs for data instead of state.
•useRef stores a mutable value without causing re-render.
•To forward a ref, use forwardRef.
Was this answer helpful?