It won't hurt to try

2. flex 본문

JS/【yarn+nodejs】mobile_web

2. flex

yongki.doki 2021. 4. 30. 01:05

flex와 flex direction에 대해서 알아보자.

import { StatusBar } from "expo-status-bar";
import React from "react";
import { StyleSheet, Text, View } from "react-native";

function App() {
  return (
    <View style={styles.container}>
      <View style={styles.yellowView}></View>
      <View style={styles.blueView}></View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    /* 
      모바일에서는 flex direction의 default가 column이다, 
      그래서 row로 바꾸려면 flexDirection: "row"로 해줘야 한다.
    */
    // flexDirection: "row",
    /* 
      기본값(센터)
    */
    // alignItems: "center",
    // justifyContent: "center",
    flex: 1,
  },
  yellowView: {
    flex: 1,
    backgroundColor: "yellow",
  },
  blueView: {
    flex: 1,
    backgroundColor: "blue",
  },
});

export default App;

300x250
300x250

'JS > 【yarn+nodejs】mobile_web' 카테고리의 다른 글

3. @react-navigation/native  (0) 2021.04.30
1. 환경구축 - expo  (0) 2021.04.29
Comments