Check out example codes for "css image fit in div with aspect ratio". It will help you in understanding the concepts better.

Code Example 1

background-image: url("images/DSELOGO trasparente.png");
background-size:contain;
background-repeat:no-repeat;

Code Example 2

img {
    width: 100%;
    height: 100%; 
    object-fit: contain;
}

Learn ReactJs, React Native from akashmittal.com