0
I get the following array of an API:
Array Exam:
[
{
id: 2,
question: 'Questão 1:',
essay_question: false,
value: '2.00',
options: [
{
id: 1,
option: 'Opção A',
correct: false,
question_id: 2,
},
{
id: 4,
option: 'Opção B',
correct: true,
question_id: 2,
},
],
},
{
id: 3,
question: 'Questão 2:',
essay_question: false,
value: '2.00',
options: [
{
id: 5,
option: 'Opção A',
correct: false,
question_id: 2,
},
{
id: 6,
option: 'Opção B',
correct: true,
question_id: 2,
},
],
},
];
I need to iterate and display the array options like radio Buttons. I am iterating the Exam array as follows:
{exam.map(e => (
<li key={e.id} >
<p>{e.question}</p>
<RadioInput name="user" options={[e.options]} />
</li>
))}
I’m using the unform (https://unform.dev/examples/radio) to register inputs.
The Radioinput component is the one from the gist below, I copied in the same way as it is on the site with the documentation: https://gist.github.com/fredarend/b50103f73ba682510bf951326620250e
However I have several questions, the id of the options array is of type number and not string, I have no items in the options array called value and not label, only id and option. I’m not getting the right way to implement this component.