1

So i am learning about refs (in react native). On react site here, it says that;

For example, instead of exposing open() and close() methods on a Dialog component, pass an isOpen prop to it.

Thus, not recommending using refs too much.

Please explain why?

What is the down point of using refs and why reactjs.org says so.

Irfan wani
  • 4,084
  • 2
  • 19
  • 34
  • 1
    React’s preference is to deal with components declaratively, re-rendering them with new props in case you need to modify them. There are certain cases (such as listed in the document) where it’s not convenient or not possible. There you can use refs to effect the components imperative let. However, it should be exceptions rather than rules, in order to stay within the React paradigm. – GRZa Jan 23 '22 at 17:06
  • Ok thanks....But i have a case here...please correct me if i am wrong. So i am showing a dialog box using props and the value of the prop is stored in redux store as i need to handle it from other component but it takes much more time to show than other components which i show using refs..... – Irfan wani Jan 24 '22 at 02:27

0 Answers0