T
T
TheSnegok2021-08-30 03:28:15
React
TheSnegok, 2021-08-30 03:28:15

How to pass a ref to a child component?

You need to pass a ref to a child component in a functional component, with such a transfer, an error at random , tell me if it is possible to somehow transfer it to a functional component or you need to use a class one, the official documentation says that you can’t transfer it in a functional component, but suddenly someone could)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexandroppolus, 2021-08-30
@Alexandroppolus

On the first render ref.current === null
Yes, and not a ref is needed here, but useState. You can’t cook porridge with a ref, there will be no updates, it is used for something else.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question