0

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.

Lucca
  • 57
  • 7
  • 2
    Yes it should work but your returning the function itself. If you want it to run directly you should do : `return function2();` – OneQ Jan 06 '23 at 22:35
  • Does this answer your question? [Functions that return a function](https://stackoverflow.com/questions/7629891/functions-that-return-a-function) – Kirill Novikov Jan 07 '23 at 16:13

0 Answers0