Hi Guys i am currently building a questionnaire using react js .
I have to display the different types of questions . Which means if backend have type of checkbox questions . Then i need to display the checkbox type questions
/**
-
Module - Answer Option Check box
-
Date - 16.06.2020
*/
import React from ‘react’;
import PropTypes from ‘prop-types’;
import Form from ‘react-bootstrap/Form’;
function AnswerOptionCheck(props) {
return (
<Form>
{['checkbox'].map((type) => (
<div class="check-box">
<div key={`default-${type}`}>
<Form.Check
className="checkboxButton"
name="checkBoxGroup"
type={type}
id={props.answerType}
label={props.answerContent}
/>
</div>
))}
)
}
AnswerOptionCheck.propTypes = {
answerType: PropTypes.string.isRequired,
answerContent: PropTypes.string.isRequired,
answer: PropTypes.string.isRequired,
onAnswerSelected: PropTypes.func.isRequired
};
export default AnswerOptionCheck;
I have created an array to check because the api is not build yet. index.js
var quizQuestions = [
{
question: "What was your position?",
type :"checkbox",
answers: [
{
content: "Project Management Assistant"
},
{
content: "Junior Project Manager"
},
{
content: "Project Manager"
},
{
content: "Project Manager"
},
{
content: "Project Manager"
}
]
}
]
what i am trying to do is if i have multiple questions in the array how can i possibly display the only check box type questions. I have attached the images