0

More of an observation than a question. When passing a ref down through props from a parent component to a child component. If we pass the prop down using the word ref, such as ref={x}, we then get an error telling us we must use React.forwardRef. But if we just pass the ref as anything else other than ref, such as inputRef={x} all works fine and we no longer receive the error. I am sure I should be using React.forwardRef but I'd like to know if the above is also acceptable?

  • ref is an attribute to access DOM elements, and perform actions like focus, add listeners, etc. If you need to perform some actions on a custom component use forwardRef, but dont try to use fordardRef to pass data between components – Azzy Nov 27 '22 at 10:22

0 Answers0