https://reactnative.dev/docs/dimensions
Dimensions · React Native
useWindowDimensions is the preferred API for React components. Unlike Dimensions, it updates as the window's dimensions update. This works nicely with the React paradigm.
reactnative.dev
import {Dimensions} from 'react-native';
const windowWidth = Dimensions.get('window').width;
const windowHeight = Dimensions.get('window').height;
// 다른 표현 방법
const {width: windowWidth, height: windowHeight} = Dimensions.get('window');
// style에 적용
const styles = StyleSheet.create({
test : {
width: windowWidth,
height: windowHeight
}
});
'FrontEnd > React Native' 카테고리의 다른 글
[react native] 텍스트 입력 textInput (0) | 2023.02.25 |
---|---|
[react native] 터치 이벤트 컴포넌트 (0) | 2023.02.25 |
[react native] 위치정보 가져오기 (expo) (0) | 2023.02.25 |
[react native] 화면 스크롤 하기 (0) | 2023.02.24 |
[react native] 프로젝트 생성 (expo) (0) | 2023.02.24 |