React form ref issue in Safari while using useRef

Viewed 483

I have a form in a Modal which is submitted by a button outside the form. I am using useRef to create a reference of the form and then submitting it on button click.

const formRef = useRef(null);

const form = (
<Form onSubmit={onSave} ref={formRef}>
.
.
.

</Form>
)

 <CustomModal
  body={form}
  onPrimaryClick={() => {
    formRef.current.requestSubmit();
  }}
/>

This code works perfectly on Chrome and Firefox but throws a TypeError on Safari I.current.requestSubmit is not a function enter image description here

I am not sure what I am doing wrong here and why the code works in other browsers.

0 Answers
Related