I have a radio group in a form which uses react-hook-form
's useForm
hook. Note that the form's mode is set to onChange
instead of onSubmit
. Both the radio inputs in the group require two clicks to be checked off but, their values are being properly set in one click.
This short GIF will explain my problem better: https://i.stack.imgur.com/GoFAj.jpg
Radio group:
<div>
<label>Radio group label...</label>
<div>
<div>
<label>
<span>Yes</span>
<input
name="radioName"
type="radio"
value={true}
ref={register}
/>
</label>
</div>
<div>
<label>
<span>No</span>
<input
name="radioName"
type="radio"
value={false}
ref={register}
/>
</label>
</div>
</div>
</div>
This is the onChange method for the entire form (the console.logs in the GIF are from here):
const handleFormChange = data => {
console.log(data.radioName)
}
What should I do to have the radio inputs get checked off in one click? Any help is greatly appreciated!