Byteclaw / visage

Visage design system
https://visage.design
MIT License
12 stars 3 forks source link

[Radio/Checkbox] - default checked is not set when used with react-hook-form #658

Closed michalkvasnicak closed 3 years ago

michalkvasnicak commented 3 years ago

Consider this code:

<Radio name="test" value="on" ref={register} />
<Radio name="test" value="off" ref={register} />

If you set default value of test to either of these values, defaultChecked is not set. But it works if react-hook-form is not used. Seems like problem with a check detection, react-hook-form probably does not set the value so maybe this can be solved only by Controller?

michalkvasnicak commented 3 years ago

Closing this as won't fix. Why? We need to have checkbox / radio controlled so we can control its UI appearance. It's not possible with simple HTML native way using :checked prop because we use a logic that depends on checked state. You have to use Controller from react-hook-form to make this components work.