I have a form in one of my React components, and and in the outside component that calls it I want to pass a reference to a button there, so that I can also submit that usin
You can achieve this by using regular HTML capabilities (HTML form Attribute), no need to use the React hacks:
Add "id" attribute to your form: id='my-form'
class CustomForm extends Component {
render() {
return (
);
}
}
Then add the same Id to the "form" attribute of the target button outside of the form:
Now, the 'Outside Button' button will be absolutely equivalent as if it is inside the form.
Note: This is not supported by IE11.