Ref={register} Inside Is Giving Me A Path.split Error
Hi I'm trying to make a form with React and when I put ref={register} inside I get the fo
Solution 1:
The way to register inputs has changed in react-hook-form v7.0.0 (the version you're using).
From the docs,
registermethod is no longer occurred atref, instead invoke the function itself and spread the props into the input. The function itself will return the following props:onChange,onBlur, name andref.- <input ref={register({ required: true })} name="test" /> + <input {...register('name', { required: true })} /> + <TextInput {...register('name', { required: true })} />
<input
className="form-control"
{...register('text')}
type="text"
/>
Solution 2:
According to new Version (7.x.x) You have to pass the register Like this
<input {...register('test', { required: true })} />
in 6.x.x it was like
<input inputref={register('test', { required: true })} />
Post a Comment for "Ref={register} Inside Is Giving Me A Path.split Error"