App.jsx
<Provider store={store}>
<Main {...this.props} ref={this.props.setRef}>
</Provider>
I want to set ref in the component. I want to call the method of the main component in my service file using reference.
App.jsx
<Provider store={store}>
<Main {...this.props} ref={this.props.setRef}>
</Provider>
I want to set ref in the component. I want to call the method of the main component in my service file using reference.
refs only work with DOM element, they don't work with React component. However, if you want a ref to one DOM element rendered by Main, it's possible to do it using forwardRef