
import { StatusBar } from "expo-status-bar";
import { StyleSheet, Text, View } from "react-native";
console.log("hello")
export default function App() {
return (
<View style={styles.container}>
<Text></Text>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});
container style์ ์ ๊ฑฐํ๋ฉด, ๋์น๊ฐ ์๋ ํ๋ซํผ๊ณผ ๊ฐ์ ๊ฒฝ์ฐ ์ด์ ๊ฐ๋ ค์ง๊ฑฐ๋ ์๋จ ์๋ก ์ฌ๋ผ๊ฐ์ ๋ ์ด์์์ด ๊นจ์ง๋ ๋ฌธ์ ๊ฐ ๋ฐ์ํ ์ ์๋ค.
- ์ด๋, ๊ฐ ๊ธฐ๊ธฐ๋ง๋ค ๋ํ ํ๋ฉด ๋น์จ์ด ๋ค๋ฅด๊ธฐ ๋๋ฌธ์, React Native์์๋
SafeAreaView๋ผ๋ ์ปดํฌ๋ํธ๋ฅผ ์ ๊ณตํจ.- ์ด์ ๋ฐ๋ผ์ ์์๋ ์ผ๋ถ๋ถ ์๋์๋ ์ผ๋ถ๋ถ(ํ๋ฒํผ๊ณผ ๊ด๋ จ๋ ๊ธฐ๋ฅ์ด ๋ ์ฐ์ ๊ถ์ ๊ฐ์ ธ์, ๋ฒํผ ๋ฑ์ ์ปดํฌ๋ํธ๊ฐ ์ ๋๋ก ๋์ํ์ง ์์ ์ ์์ผ๋ฏ๋ก) ์ฌ์ฉํ์ง ์๋๋ก ์กฐ์ ํด์ค
- ์๋๋ก์ด๋์ ๊ฒฝ์ฐ ์ด์์ฒด์ ์๋จ์ ์ํ๋ฐ๊ฐ ์กด์ฌํจ, ์ด๋ ์ํ๋ฐ์ ์ํด ์ปดํฌ๋ํธ ์ผ๋ถ๊ฐ ๊นจ์ง๋ ๊ฒฝ์ฐ๊ฐ ์์, ๋ฐ๋ผ์ ์ด๋ฅผ ๋ ์ด์์์ธก๋ฉด์์ ์ก์์ฃผ์ด์ผ ํจ
์ด๋ ์ฌ์ฉํ๋ ํจํค์ง๋Constantsimport Constants from 'expo-constants';ํจํค์ง๋ฅผ ๋ถ๋ฌ์ค๊ณ ,paddingTop: Constants.statusBarHeight,style์ ์ด๋ฅผ ์ ์ฅ but ์์ดํฐ์์๋ ์ธ๋ฐ ์๋? ๋น ๊ณต๊ฐ์ด ์๊ธธ ์ ์๋ค๋ ๋จ์ ์ด ์กด์ฌ- ํ๋ซํผ์ ์ง์ ํ ํ ์ด๋ฅผ ์ฌ์ฉํ ์ ์๊ฒ ํจ
Platform์ ์ด์ฉ
paddingTop: Platform.OS === 'android' ? Constants.statusBarHeight : 0
Padding, Row์ ๊ฐ์ style์ ์์ฒด component๋ก ๋ฐ๊พธ์ด์ ์ค์ ํด ์ฃผ๊ธฐ
App.js<Padding padding={12}> <TodoItem /> <Row> <TextInput style={styles.input} /> <Button title="Send" onPress={() => {}} /> </Row> </Padding>Padding.js
function Padding({ children, padding }) { return <View style={{ padding: padding ?? 20 }}>{children}</View>; }
### Expo checkbox