I'm following the documentation (https://inertiajs.com/forms) of Inertia for custom submit button using the <Form ...> component.
It show as example:
import { useRef } from 'react'
import { Form } from '@inertiajs/react'
export default function CreateUser() {
const formRef = useRef()
const handleSubmit = () => {
formRef.current.submit()
}
return (
<>
<Form ref={formRef} action="/users" method="post">
<input type="text" name="name" />
<button type="submit">Submit</button>
</Form>
<button onClick={handleSubmit}>Submit Programmatically</button>
</>
)
}
But I need a type for formRef, because the line formRef.current.submit() is warning in TS.
I try with HTMLFormElement but still showing errors.
What are the corrects types here?
I expect to TS don't show errors in my IDE.
I tried
const formRef = useRef<HTMLFormElement | null>(null);
Thanks
Type 'RefObject<HTMLFormElement | null>' is not assignable to type 'Ref<FormComponentSlotProps> | undefined'... butFormComponentSlotPropsdoesn't exists. So I try to change it but always I got a new error