#Show value onClick segmented control
5 messages · Page 1 of 1 (latest)
you need to adapt the code to do this
for example, the [active, setActive] should become two different states instead of one
e.g.
accountActive, setAccountActive
generalActive, setGeneralActive
you then need to refactor the const links with ternaries: change the item.label === active to check depending on section
item.label === (section === 'account' ? accountActive : generalActive)
and do the same in onClick
if (section === 'account')
setAccountActive(item.label)
else
setGeneralActive(item.label)
ah, do you want to replace the links entirely?
just use a ternary
{section === 'account' ? (
<AccountForm/> :
<GeneralForm/>
)}