How to submit form from a button outside that component in React?

后端 未结 6 1003
野趣味
野趣味 2020-12-31 02:07

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

6条回答
  •  死守一世寂寞
    2020-12-31 02:25

    You can pass the submit function as a prop and use this method whenever you want. for more complex situations you can use redux save your form data on redux and whenever the button is clicked you read data from redux and submit them

提交回复
热议问题