Skip to content
Advertisement

Accessing button using ref

I’m not able to access the button using ref. Below is my code sample, In I keeping the undefined for completeSubmissionButton. I’m not sure what’s the solution for it.

JavaScript

Advertisement

Answer

You can’t provide a ref to React component ,ref only work in a native html element so you need to pass your Button component into forwardRef fn

JavaScript

https://reactjs.org/docs/forwarding-refs.html

https://reactjs.org/docs/hooks-reference.html#useref

https://reactjs.org/docs/refs-and-the-dom.html

Advertisement