Nested useForm() inputs, Self-Rendering useForm(), Yup schemas validation and React-window inputs
//The <ConnectForm> children render prop function will receive
//Its {...methods} argument from the parent
const ConnectForm = ({ children }) => {
const methods = useFormContext()
return children({ ...methods })
}
const DeepNest = () => (
<div>
<ConnectForm>
{({ register }) => (
<div>
<input {...register("nested1")} placeholder="Input 1" />
<input {...register("nested2")} placeholder="Input 2" />
</div>
)}
</ConnectForm>
<Primo /> <Secondo />
<div>
)
function Testa(){
const methods = useForm()
return(
<FormProvider {...methods}>
<form>
<DeepNest />
<input type="submit" />
</form>
</FormProvider>
)
}Self-Rendering Form Components
Implementing Yup schemas for form validation
Virtualized useForm() inputs with React-Window
PreviousThe <errorMessage> component, useWatch() hook and multi-page funnel useForm().NextJest testing, useMemo() inputs, controlled inputs and onChange() value parsing
Last updated