I am passing onLongPress on a Component that has the same function as onClick. I have used useState
for both. When I long press the item it opens the menu but again if I Long press the menu stays open.
const resetNavItems = () => {
setIsFirstComponentOpen(false);
setIsSecondComponentOpen(false);
}
const onClickItem = useCallback(index => {
resetNavItems();
if (index === 2) {
setIsFirstComponentOpen(!FirstComponentOpen);
} else if (index === 3) {
setIsSecondComponentOpen(!SecondComponentOpen);
}
});
<TouchableOpacity onLongPress={onClickItem} />