728x90
parent view의 속성 onLayout을 이용하면
event.nativeEvent.layout.height를 통해 height를 알 수 있다.
import React, {useState} from 'react';
import {View} from 'react-native';
export default ({routine, onMidBtnPress, children}: Props) => {
const [parentHeight, setParentHeight] = useState(0);
const onLayout = event => {
const {height} = event.nativeEvent.layout;
setParentHeight(height);
};
return (
<View style={{width: 100, height: 100}} onLayout={onLayout}>
<View
style={{
position: 'absolute',
width: '100%',
height: parentHeight,
backgroundColor: 'pink',
opacity: 0.5,
alignSelf: 'center',
}}
/>
</View>
);
};
출처
'Develop > React Native' 카테고리의 다른 글
[React Native] WebView 사용법 (0) | 2020.05.11 |
---|---|
[React Native] build가 영원히 되지 않을 때 (2) | 2020.05.10 |
[React Native] library not found for -lAppAuth / Build input file cannot be found:에러 (0) | 2020.05.04 |
[React Native] react16 redux (0) | 2020.05.03 |
[React Native] Animated 사용법 (내용없음) (0) | 2020.05.01 |