Check out example codes for "node js check if a user exists in mysql". It will help you in understanding the concepts better.

Code Example 1

connectDB.query("SELECT ACCOUNT_ID FROM registration WHERE ACCOUNT_ID = '"+ userAccnt +"'", function(err, result, field){
     if(result.length === 0){
        //new user logic
}else{  
    //existing user, redirect to another page 
 }
        }

Learn ReactJs, React Native from akashmittal.com