Unable to pass child refs to parent in reactjs

Unable to pass child refs to parent in reactjs


Hi ,
I have a reference element in my child component (only html) and now would need to render it in parent class.

Can someone advise?


I’m not entirely sure what you are asking, but:

In React the preferred method of communication between parent and child is through declarative props.

Refs are somehow discouraged and generally used for very few case:
Quoting the

There are a few good use cases for refs:
Quoting from the docs

Managing focus, text selection, or media playback.
Triggering imperative animations.
Integrating with third-party DOM libraries.

Avoid using refs for anything that can be done declaratively.

Perhaps if you can provide us a working example or some code we could help you find a solution. :+1:


This is something React very much does not want you to do, and for good reason. What is it that you’re trying to accomplish?