I was reading the React “refs and the DOM” section. I don’t understand this line.
“Avoid using refs for anything that can be done declaratively”. can anyone explain what does this line mean?
Refs are sort of an anti-pattern in how UIs are supposed to be built in React.
- Accessing the DOM element directly is not heavily smiled upon
- It is preferred to work with state and props and indirectly get your UI get updated
Welcome to the forums @shahab570!
Cheers,
Kirupa