How to insert properties and functions inside ref?

How can I insert properties and functions inside a ref? Like this example: Then I want to use the propertie loading and the function onTest that way: How can I do that? Answer You cannot set ref on functional components because they don’t have an instance. You may not use the ref attribute on function components because they don’t have instances. (source: https://reactjs.org/docs/refs-and-the-dom.html#accessing-refs) To make your example working you need to convert <MyComponent /> to class component.