## React-Native-Seoul meetup ##
- React-Native 초심자를 위한 실습위주의 간단한 소개 및 구현법 안내
## 발표자 ##
박태성
아이디어샘 R&D Dev Specialist
geoseong@ideasam.net
@geoseong by Slack
4. react-native
프로젝트 생성
CLI 입력
$ react-native init [프로젝트명]
ex) $ react-native init AnnyeongRN
참고문서
Getting Started -> Building Projects with Native Code
5. <App.js>
import React, { Component } from 'react';
import { Text, View } from 'react-native';
export default class App extends Component {
render() {
return (<View style={{flex: 1}}>
<Text style={{textAlign: 'center',}}>
AnnyongRN!
</Text>
</View>)
}
}
대략적인 실행 원리
● index.js에서 시작
● AppRegistry.registerComponent의 두번째
인자 부분의 클래스를 참조
● index.js에서 참조하는 해당 클래스에서
본격적인 코딩이 이루어짐
react-native
프로젝트 생성
<index.js>
import { AppRegistry } from 'react-native';
import App from './App';
AppRegistry.registerComponent('AnnyeongRN', () => App);
6. Styling : flexbox
flexbox
일반 웹의 css에서는 display: flex 로 사용
flex
● DOM 컨테이너들의 너비를 채워줌 . 숫자로 표현.
● 1 이면 flex 속성 할당된 컨테이너 각 비율에 맞게 할당
● 2 이면 컨테이너 각 비율 x2
justifyContent
● 세로정렬. 양쪽균등정렬과 좌우정렬 가능
alignItems
● 가로정렬. 양쪽균등정렬과 좌우정렬 가능
공식문서
http://facebook.github.io/react-native/docs/0.55/flexbox
flex개념을 잡아주는 게임 사이트
flexboxfroggy.com
11. 시뮬레이터준비 - 참고문서
https://facebook.github.io/react-native/docs/getting-started
공통
1. $ brew install node
2. $ brew install watchman
3. $ npm install -g react-native-cli
Android Android Studio 다운로드
iOS Xcode 다운로드
시뮬레이터돌려보기
iOS $ react-native run-ios
RN 시뮬레이터
돌려보기
** No bundle URL present 메시지가 뜬다면...
다른 터미널에서 $ react-native start 를 먼저 실행 후
시도해 본다.
12. 시뮬레이터돌려보기
Android
1. Android Studio에서 Emulator를 미리 실행을 해놔야
한다.
기기연결 확인방법 : $ adb devices
2. $ react-native run-android
처음으로Android 시뮬레이터돌리기
1. Android Studio 실행
2. 새 Empty 프로젝트 만들기
3. 상단메뉴 Tools -> Android -> AVD Manager -> Virtual
Device 생성 -> [원하는 기기] -> x86 images ->
Marshmellow System Image 다운로드
4. 다운로드 후 추가된 기기의 재생버튼 클릭
5. $ react-native run-android
RN 시뮬레이터
돌려보기