본문 바로가기
기초다지기/React Native

react-native image height 이미지 높이 자동으로 맞추고 싶을 때

by 김빵그 2023. 8. 22.
 

GitHub - vivaxy/react-native-auto-height-image: 🖼️React native auto height image

🖼️React native auto height image. Contribute to vivaxy/react-native-auto-height-image development by creating an account on GitHub.

github.com

yarn add react-native-auto-height-image

npm install react-native-auto-height-image
import React, { Component } from 'react';
import AutoHeightImage from 'react-native-auto-height-image';

import image from 'gallifrey-falls.png';

export default class Demo extends Component {
  render() {
    return (
      <View>

        <AutoHeightImage
          width={100}
          source={image}
        />

        <AutoHeightImage
          width={100}
          source={{uri: 'http://placehold.it/350x150'}}
        />

      </View>
    );
  }
}
  • 이미지의 높이를 자동으로 너비의 퍼센트에 따라 유동적으로 조정하려면 위와 같은 코드를 사용하면 된다