ReactJS - 从父组件提交表单?

时间:2017-10-19 14:13:58

标签: javascript reactjs

有没有办法从父组件提交表单而不使用refs?

这是我的代码:

const ModalWindow = ({ close }) => {
  const form = <MyForm />;

  return (
    <Modal show>
      <Modal.Body>
        {form}
      </Modal.Body>
      <Modal.Footer>
        <Button onClick={close}>Cancel</Button>
        <Button onClick={form.submit}>Submit</Button>
      </Modal.Footer>
    </Modal>
  );
};

1 个答案:

答案 0 :(得分:0)

您可以执行<form onSubmit={}>,这会在您的组件中触发column.setOnEditCommit((TableColumn.CellEditEvent<MyObject, Date> t) -> { //modify the rendering of you cell to normal });