forwardRef/ref prop schizm?

Hi
I see in the docs that forwardRef is discouraged, but at the same time got a error from the compiler that i must use forwardRef (only if the prop was named ref?). Can anyone break the tie for me?

Thanks
Alex

Uh oh… we should probably change that compiler warning.
Go with the recommendation on the docs, and use a normal prop instead if possible. React.forwardRef will eventually go away, even in plain ReactJS afaik.

\cc @rickyvetter

If the prop name is ref then forwardRef has to be used.
else we can pass ref via props i guess. eg( if the prop is inputRef)

Read createElement/jsx RFC for full context but forwardRef is just a lot of overhead for hooks components that doesn’t need to be there. We recommend using a different prop name so that it just works like a normal prop until this is changed in React. The deprecation message is old. Thanks for catching, we’ll update ASAP.

2 Likes