consider the following block of code:
<TextField name="name" required className='my-2 mx-auto' label="Full Name" variant="standard" style={{ "width": "60%" }} value={name} onChange={(event) => { setName(event.target.value); }} {...register({
required: "Name is required"
})} />
I have replaced the ref with ...register but I am still getting the error, can someone please help me fix it?
No you can't do this because TextField is not only an input.
I think you have to pass {...register({ required: "Name is required"})} to the TextField's input and to do that, you could use TextField's inputProps prop. Something like:
<TextField
name="name"
required
className='my-2 mx-auto'
label="Full Name"
variant="standard"
style={{ "width": "60%" }}
value={name}
onChange={(event) => { setName(event.target.value); }}
inputProps={{...register({required: "Name is required"})}}
/>