Is it possible to make a function return another function in React Native?

25 Views Asked by At

For example, im in this code that at some point an onPress calls a function: onpress={function1} and i function1 has to work like this:

function function1(){
    if(x){
        return Alert.alert("Alert!");
    }
    else{
        return function2;
    }
}

So basically when i press it, if the condition is followed it should show the alert but if its not, it should run the other function.

Is it possible? Ive been trying to do this but i couldnt find a way.

0

There are 0 best solutions below