full width of image and maintain aspect ratio react native

Solutions on MaxInterview for full width of image and maintain aspect ratio react native by the best coders in the world

showing results for - "full width of image and maintain aspect ratio react native"
Ben
23 Jan 2020
1render() {
2    let image = this.props.requireSource;
3    const { width, height } = Image.resolveAssetSource(image);
4    const ratio = height / width;
5    const SCREEN_WIDTH = Dimensions.get('window').width;
6
7    return (
8        <Image source={image} style={{width: SCREEN_WIDTH, height: SCREEN_WIDTH*ratio}} resizeMode="contain"/>
9    );
10}
11