Skip to content

renderRadioGroup

renderRadioGroup<V>(args): ReactElement

Defined in: RadioGroupBinding.ts:143

Render a radio button for each option of a radio group

V extends RadioGroupBinding.Option

(option: V, config?: RadioGroupBinding.ButtonConfig) => object

What form.bindRadioGroup() returns

readonly V[]

Options to render a radio button for, in order

(option: V, bind: (config?: RadioGroupBinding.ButtonConfig) => object, index: number) => ReactNode

Render the radio button of an option

ReactElement

  • renderOption receives the option, a bind function that returns the props of the option's radio button, and the option's index. bind takes the same overrides as the binding's second argument.
  • Each option is keyed by its value, so the element that renderOption returns needs no key.
{renderRadioGroup({
binding: form.bindRadioGroup("role", {
getter: () => model.role,
setter: (v) => (model.role = v),
}),
options: Object.values(Role),
renderOption: (role, bind) => (
<label>
<input {...bind()} /> {role}
</label>
),
})}