Last active
July 28, 2022 11:38
-
-
Save louicoder/abc226472761ac18ca11fc9131974ea3 to your computer and use it in GitHub Desktop.
Create Full Width image and Auto Height in React Native
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get screen dimensions | |
const { WIDTH, HEIGHT } = Dimensions.get(); | |
// style={{ aspectRatio: image.width / image.height }} | |
const getImageStyles = (imageWidth, imageHeight) => { | |
// WIDTH - Screen Width. | |
// HEIGHT - Screen Height. | |
return { width: WIDTH, height: imageHeight / imageWidth * WIDTH }; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment