Users select one of four options for 70 questions. The four options never change but I need to know which was selected for each question. The code below works but I am trying to determine if I should copy this code 70 times or if there is a better way? Thanks!
const [selected, setSelected] = useState({
option1: {
title: "I can think of where this has lead me",
selected: false,
},
option2: {
title: "I can think of how this has changed me",
selected: false,
},
option3: {
title: "I can think of how I overcame this",
selected: false,
},
option4: {
title: "This has an interesting backstory",
selected: false,
},
});
const selectingOption1 = () => {
setSelected({
...selected,
option1:{selected: true,
title: "I can think of where this has lead me" }
})
}
Example of displaying question:
<Card onClick={props.selectingOption1} className={classes.itemCard}>
<img className={classes.iconImg} src='/item1.png' />
<p> I can think of where this has lead me</p>
</Card>