-
Hello everybody. export default function RadioButton ({ name, id, value, label, onChange, register, required = false }) {
return (
<label htmlFor={id}>
<CheckAltIcon />
<input
type="radio"
name={name}
id={id}
value={value}
onChange={onChange}
{...register(name, { required })}
/>
{label}
</label>
)
} And the parent component(Form) where it is called looks like this: return (
<form className={styles.Form} onSubmit={handleSubmit(onSubmit)}>
<div className={styles.ControlGroup}>
<label>Seleccionne una institución:</label>
<div className={styles.RadioGroup}>
{
array && array.map(someItem => (
<RadioButton
key={someItem .id}
name="someName"
id={`field-${someItem .id}`}
value={someItem .id}
isChecked={selected=== someItem .id}
onChange={handleChange}
label={someItem .name}
register={register}
required
/>
))
}
</div>
</div>
</form>
) I am following the instructions found in the documentation but I can't get this to work. If anyone can help me with this I really appreciate it. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Please provide a codesandbox sample to get more detail about the issue and some steps to re-produce if possible. |
Beta Was this translation helpful? Give feedback.
-
Solution: |
Beta Was this translation helpful? Give feedback.
Solution:
Add forwardRef when you have custom components of type Radio or Checkbox.
In the documentation it only indicates to add forwardRef to the select fields, but you must also do it for the aforementioned fields.
You should specify this type of behavior in the documentation to avoid wasting time.