So I have a screen in react-native in my android app for reporting faulty equipment on my university and I have a wierd issue with my accordion menu. I use it as a list of options for the type of broken equipment that I store and then send to the database. After testing I found out the acordion menu doesnt close even if I edit the function to change the state that should track if the menu shoudl be open or not. Anybody any ideas?
const [typeOfEquip, setTypeOfEquip] = useState('');
const [expanded, setExpanded] = React.useState(true);
const chooseType= (typ) =>{
setTypeOfEquip(typ);
handlePress();
}
const handlePress = () => setExpanded(!expanded);
<List.AccordionGroup>
<List.Accordion
title="Type of equipment"
expanded={expanded}
onPress={handlePress}
id="1">
<List.Item
title="Svetla"
onPress={() => {
chooseType('Svetla');
}}
/>
<List.Item
title="Stoličky"
onPress={() => {
chooseType('Stoličky');
}}
/>
</List.Accordion>