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} />
P粉0193532472023-09-11 12:46:05
You can use the defaultChecked
attribute on input
elements.
For example:
<input {...register("car")} type="checkbox" defaultChecked={data.car ? true : false} />