🎸/React Native

[ React Native ] 리액트 네이티브 기본강좌: 3강 Hello world(2)

컴공생 C 2021. 2. 5. 14:36
반응형

Expo CLI vs React-Native CLI

Expo CLI 장점

  •  편리한 배포, 디버깅
  • expo에서 제공하는 편리한 기능 사용
  • 추가적인 Native 코드 작성아 불가 (eject를 통해 가능하지만..)

React-Native CLI 장점

  • Xcode, android studio를 통해서 Native 코드 확장이 가능 (카카오톡 연동고 같은 기능이 필요할때)
  • 개인적으론 React-Native로 개발하는 것을 추천

 

React Native Helloworld 실행 및 구조

Hello world 출력하기 코드

App.js 코드

import React from 'react';
import {
  SafeAreaView,
  StyleSheet,
  ScrollView,
  View,
  Text,
  StatusBar,
} from 'react-native';

import {
  Header,
  LearnMoreLinks,
  Colors,
  DebugInstructions,
  ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';

const App = () => {
  return (
    <View>
      <Text>Hello,world!</Text>
    </View>
  );
};


export default App;

실행화면

레이아웃 설정 코드

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow strict-local
 */

import React from 'react';
import {
  SafeAreaView,
  StyleSheet,
  ScrollView,
  View,
  Text,
  StatusBar,
} from 'react-native';

import {
  Header,
  LearnMoreLinks,
  Colors,
  DebugInstructions,
  ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';

const App = () => {
  return (
    <View style={styles.container}>
      <Text style={styles.hello}>Hello,world!</Text>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center', //위아래 중간 맞추기
    alignItems: 'center', //좌우로 중간 맞추기
  },
  hello: {
    color: 'red',
  },
});

export default App;

 

실행화면

반응형