본문 바로가기

React Native 공부

React Native 공부 3 - 프레임워크

반응형

https://facebook.github.io/react-native/


JavaScript와 React Native를 사용하여 모바일 어플을 개발할 때, 전체적인 틀이 위의 URL에 들어가면 자세히 나와있다.


1. 가장 기본적인 틀 - 위의 import문 두 줄은 필수적으로 써주는 것이 좋다 

import React, {Component} from 'react';

import {Text, View} from 'react-native'; class HelloReactNative extends Component { render() { return ( <View> <Text> If you like React, you'll also like React Native. </Text> <Text> Instead of 'div' and 'span', you'll use native components like 'View' and 'Text'. </Text> </View> ); } }



2. native code를 불러와서 쓸 경우 - 다음과 같이 Swift, Java, Objective-C로 쓰인 components들도 react native에서 불러 쓸 수 있다.

import React, {Component} from 'react'; import {Text, View} from 'react-native'; import {MapViewComponent} from './your-native-map-implementation'; class CustomMapView extends Component { render() { return ( <View> <MapViewComponent /> <Text> MapViewComponent could use native Swift, Java, or Objective-C - the product development process is the same. </Text> </View> ); } }

반응형

'React Native 공부' 카테고리의 다른 글

React Native 공부 6 - State & Style  (0) 2019.01.07
React Native 공부 5 - Props  (0) 2019.01.07
React Native 공부 4 - Learn the Basics  (0) 2019.01.07
React Native 공부 2  (0) 2018.12.29
React Native 공부 1  (0) 2018.12.25