React ternary operator



var isLoggedIn = false;
var domain = 'pt';
var passwordLogin = false;
var b = false;
var c = false;



let message = (isLoggedIn === true && domain != 'pt') ? <Component {...props} /> :
  (isLoggedIn === true && config.domain == 'pt' && passwordLogin === true) ? <Component {...props} /> :
  (isLoggedIn === true && config.domain == 'pt' && passwordLogin == false) ? <Redirect to={{ pathname: '/newlogin' }} /> :
  (isLoggedIn === false && config.domain==='pt') ? window.location.replace('http://n.com/pt/360-vr?device=smart&offer=1') :
  <Redirect to={{ pathname: '/login' }} />

alert( message );


            

No comments:

Post a Comment