I have 3 different Accordions that a single state controls their open and close state like so:
const [accordionOpen, setAccordionOpen] = useState({
countryOfOriginAccordion: true,
schoolAccordion: false,
areaOfStudyAccordion: false,
});
ideally, I am setting each state with their own function like this:
setAccordionOpen((previousState) => ({
...previousState,
schoolAccordion: !accordionOpen.schoolAccordion,
}))
I want to use a single function that changes this value in state dynamically: