lundi 25 novembre 2019

Conditionally return data

I have this function

 getFace(/* string */ face_name, /* int */ w, /* int */ h, /* int */ z) {
    const am = this.props.assetsManager;
    return {
      backgroundSize: 'contain',
      position: 'absolute',
      width: `${w}px`,
      height: `${h}px`,
      zIndex: z
  };

If face_name is let say face2 i need to return an additional style i.e backroundColor: red How do i add condition to the return statement in React

Aucun commentaire:

Enregistrer un commentaire