C
C
cester2018-05-22 15:32:05
JavaScript
cester, 2018-05-22 15:32:05

Custom radio buttons in react?

Good afternoon! Please tell me how to make custom radio buttons?
The project on react , you can use lodash or via createSelector
The radiobuttons are already laid out, the only problem is how to show the selected radiobutton.
An array of objects comes, and in the object it is necessary to change the property enabled: true
, respectively, in another object, this property must be replaced by false.
The question is how best to write this implementation?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-05-22
@cester

{radios.map(radio => (
  <Radio
    key={radio.value}
    enabled={radio.value === this.state.value} 
  >
    {radio.label}
  </Radio>
))}

The active element is not necessarily stored in state , it can also come in props

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question