ISSUE: Id attributes is applied to all elements.
Request: I am trying to add id attribute to an element that consists of 3 checkbox, but i'm not sure how to do that. I tried to add it to the main one but it applied to all.
import GTM from "/components/gtm"
offerHelp: {
prefix: "OFS",
volunteer: "_VO",
donor: "_DI",
orgbtn: "_ORG",
},
const Step1 = (props) => {
const [state, updateState] = useState(STEP_1_STATE);
const { answers, none } = state;
const toggleAnswer = (answer) => {
const updatedAnswers = { ...answers, [answer]: !answers[answer] };
const checkedAnswers = getCheckedAnswers(updatedAnswers);
updateState({ ...state, answers: updatedAnswers });
props.update("providers", checkedAnswers);
};
return (
<WizardStep>
<WizardProgress className="text-primary">
Question {props.currentStep}/{props.totalSteps}
</WizardProgress>
<StepTitle>How do you want to contribute?</StepTitle>
<WizardFormWrapper>
<WizardCheckboxWrapper>
{Object.entries(answers).map(([answer, checked], i) => (
<WizardCheckboxItem
key={i}
id={
GTM.offerHelp.volunteer +
props.currentStep +
GTM.offerHelp.orgbtn +
GTM.offerHelp.donor //this is the id where i need to fix. currently its not giving the three elements different ids. They are all the same
}
onChange={() => toggleAnswer(answer)}
checked={!none && checked}
text={answer}
/>
))}
</WizardCheckboxWrapper>
</WizardFormWrapper>
</WizardStep>
);
};
