- Published
- Author
- Rishav RajSystem Analyst
I've have a
I learn how to extract a
The
In order to fix it, a Controller component can be used.
Solution:-
Thanks 🙂
radio input in a React Hook form and attempted to pass a boolean value, however when i submit the form, i receive the typeof value as a string. Knowing that RHF has valueAsNumber to convert it as number. I thought that setValueAs was a generic way to allow any conversion but I can't make it work.I learn how to extract a
boolean value from a RHF radio input.The
setValueAs approach, which I have previously tried, only functions with text input (such as type="text" or type="number"). Even if the value for a radio button is a string, it doesn't function.In order to fix it, a Controller component can be used.
Solution:-
Code
(
{t("I'm Booking For")}
onChange(false)}
checked={value === false}
inputRef={ref}
id="myself"
/>
{t("Myself")}
onChange(true)}
checked={value === true}
inputRef={ref}
id="someone-else"
/>
{t("Someone Else")}
)}
/>Thanks 🙂