I am using Ionic with React (typescript) and I am creating my custom form builder. There I created my form that has to have a ref property, because I need a reference of it when I use it. My problem is that I don't know how to define a prop that is reference type for my custom form builder.
This is how I am using it:
const form = useRef<HTMLFormElement>(null);
return (
<IonPage>
<Header />
<IonContent fullscreen>
<Form
ref={form}
submit={() => onSubmit()}
fields={ fields }
render={() => (
<React.Fragment>
<IonCard>
<IonCardHeader>
<IonLabel>Valamilyen form</IonLabel>
</IonCardHeader>
<IonCardContent>
<Field {...fields.name} />
</IonCardContent>
</IonCard>
</React.Fragment>
)}/>
</IonContent>
<Footer />
</IonPage>
);
Here I got an error: Property 'ref' does not exist on type 'IntrinsicAttributes & IFormProps & IFormState & { children?: ReactNode; }'
My Form React.FC looks like this:
type formProps = IFormProps & IFormState;
export const Form: React.FC<formProps> = React.forwardRef<HTMLFormElement, formProps>( (props: formProps, porpsRef) => {
return (
<form onSubmit={handleSubmit} noValidate={true} ref={porpsRef} />
);
)};
I need to add to my Form component a property named ref of the reference, but I don't know how.
Thanks
I think there is small mistake. Can you please try this