Text
componet subView 또는 두 개의 Text
구성 요소 하위 뷰 중 하나를 포함하는 사용자 지정 부모 View
을 작성하고 싶습니다. Text
보기의 높이를 기준으로 상위 View
의 높이를 설정하는 방법이 있습니까?하위 뷰의 높이를 기준으로 부모 뷰의 높이를 설정하는 방법
class ParentView extends Component {
constructor(props) {
super(props);
}
render() {
const {
titleText,
bodyText,
} = this.props;
//if titleText is passed to props, measure it's height;
//if bodyText is passed to props, measure it's height;
// set contentContainer height = titleText + bodyText + someMargin
return (
<View style={styles.contentContainer}>
{titleText && <Text style={styles.title}>
{titleText}
</Text>}
{bodyText && <Text style={styles.body}>
{bodyText}
</Text>}
</View>
);
}
}
왜 부모의 높이를 설정해야하나요? 부모님이 높이, 최소/최대 및 플렉스 스타일을 생략하면 부모가 자녀를 감쌀 수 있습니다. – vovkasm
주어진 답변 중 하나를 시도해 보셨습니까? – Akis