'How to give both handleSubmit and function to one onPress?

I use react-native.

I have TouchableOpacity named SmallButton below. and if you see onPress, I give handleSubmit when it is pressed.

<SmallButton
  styleB={{ backgroundColor: `${colors.normal}` }}
  styleBT={{ color: `${colors.lightgray}`, fontSize: 20 }}
  text={"확인"}
  onPress={handleSubmit(EditValid)} // want to add navigate.goBack()
/>

it works well.

but my question is I want to navigate.goBack() after handleSubmit. But don't know how.

First I wanted to make one function like

const onClick = () => {
 handleSubmit(EditValid);
 navigation.goBack()
}

then onPress={onClick}.

but of course since handleSubmit is not a function, this handleSubmit doesn't work.

How to make it work handleSubmit and navigation both in 1 onPress?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source