I have a controlled checkbox input and I am supposed to set the default value on request but I am getting the error "Type 'boolean' is not assignable to type 'string | number | readonly string[] | undefined'". Maybe you know how to avoid this?
<input
{...register("car")}
type="checkbox"
defaultValue={data.car ? true : false}
/>
You can use the
defaultCheckedattribute oninputelements.For example:
<input {...register("car")} type="checkbox" defaultChecked={data.car ? true : false} />