Vladimirã¯6幎以äžAndroidãéçºããŠãããiOSããã³Windows Phoneåãã®ã¢ããªã±ãŒã·ã§ã³ã®äœæçµéšããããŸãã éå»1幎éã圌ã¯React Nativeã«å€¢äžã«ãªããEPAM Systemsã§ã¯ãã¹ãã©ãããã©ãŒã ã®ã³ãŒãæåãä¿é²ãå§ããŸããã
-ãªããã©ãããã©ãŒã ã³ãŒãã奜ãã§ã¯ãªãã®ã§ããïŒ ãã€ãã£ãéçºã«ã¯ã©ã®ãããªæ¬ ç¹ããããŸããïŒ
Vladimir IvanovïŒãã¹ãŠã®ãã©ãããã©ãŒã ã«ã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ãå¿ èŠã ãšé¡§å®¢ãèšããšããAndroidãiOSãããã³Windowsãæ ¹æ¬çã«ç°ãªãããšãç解ããŠããŸããã ãœãããŠã§ã¢éçºè ã¯ã2ã€ãŸãã¯3ã€ã®ãã©ãããã©ãŒã ã§åãã³ãŒããåãããžãã¹ããžãã¯ãç¹°ãè¿ãå¿ èŠããããŸãã
ãã©ãããã©ãŒã èªäœã«ãããŸããŸãªçš®é¡ããããŸãã iOSã®iPhoneã«ã¯ãããŒãžã§ã³ãæ©èœãç»é¢ãµã€ãºã®ãªãã·ã§ã³ããããŸãã ãŸããAndroidã§ã¯å£æ» çãªå²åã«éããŸãã2.3以éã®ããŒãžã§ã³ã ãã§ãªããèšå€§ãªæ°ã®ããã€ã¹ããµããŒãããå¿ èŠããããŸãã ããã«ããããã€ãã£ãéçºãé¢åãªäœæ¥ã«ãªããŸãã
äŸãæããŸãããã Githubã«Flick Feed React Nativeæè²ãããžã§ã¯ãããããŸãã 2ã€ã®ã¢ãã€ã«ãã©ãããã©ãŒã ã§åèšçŽ100è¡ã®ã³ãŒãããããŸãã ãŸããAndroidã®BitBucketã«ãåæ§ã®ãããžã§ã¯ãããããæ°å¹Žåã«ãããè¡ããŸããã ã³ãŒãã®å°çããããããã«æ¡éãã«ãããããã¯ãã ã®Androidã¢ããªã§ãïŒ ãããèŠãŠãã ããïŒ
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="#FFF" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@+id/thumb" android:adjustViewBounds="true" android:layout_margin="10dip" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <LinearLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:id="@+id/published" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/common"/> <TextView android:id="@+id/desc" android:ellipsize="end" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/common"/> </LinearLayout> </LinearLayout>
ããã¯ãã£ãŒãããã®1ã€ã®èŠçŽ ã®ã¬ã€ã¢ãŠãã§ã36è¡ãããããžãã¯ã¯ãããŸããã ãŸããã¢ã¯ãã£ããã£ã調ã¹ãå¿ èŠããããŸãããã¥ãŒãæ¢ããŠå€ãå ¥ããã³ãŒãããããŸãã ããã§ããèŠçŽ ã«å¯ŸããŠèšããŸããå¿ èŠããããŸãã
RNã®åãèŠçŽ ã«ã¯21è¡ãå¿ èŠã§ããå€ãèšå®ããããžãã¯ã¯æ¢ã«ãããŸãããinflateã¯ãŸã£ããå¿ èŠãããŸããã
import React from 'react'; import { View, Image, Text } from 'react-native'; export default ({ flickrItem }) => { return ( <View style={{ flexDirection: 'column', padding: 8, borderWidth: 2, borderColor: 'black', margin: 8 }}> <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}> <Text>{flickrItem.title}</Text> <Text>{flickrItem.date}</Text> </View> <Image source={{ uri: flickrItem.url }} style={{ marginTop: 16, width: 200, height: 200 }}/> </View>); }
- ã¢ãã€ã«éçºçšã®äŸ¿å©ãªã¯ãã¹ãã©ãããã©ãŒã ãã¬ãŒã ã¯ãŒã¯ãäœæããããšããè©Šã¿ã¯ãæ°å¹Žéç¶ããŠããŸãã æ確ãªãªãŒããŒããéã®åŒŸäžžããç»å ŽããŠããŸããã ãªãã§ïŒ
Vladimir IvanovïŒ AndroidãšiOSã®ç»å Žä»¥æ¥ãã³ãŒãå ±æã®åé¡ã解決ããããšããå€ãã®è§£æ±ºçããããŸãã ãããã¯ãPhoneGapãTitaniumãªã©ã§ãã
ç§ã®å®åã§ã¯ã人ã ã¯ãã®ãããªãã¬ãŒã ã¯ãŒã¯ãããžãã¹ã®ã¢ã€ãã¢ããã¹ãããããã ãã«äœ¿çšããŠãããšæããŸãã 圌ãã¯ãã¢ããªã±ãŒã·ã§ã³ãæ¬åœã«æ©èœããŠããããšãç解ããããšãå¯èœã«ããããã䜿çšããã®ã䟿å©ã§ãããããžãã¹ã®ã¢ã€ãã¢ã¯æ®éã§ãã ãã¹ãŠãããã§ããã°ããã€ãã£ãéçºã§ã¯ãã¹ãŠãéåžžã©ããã«æ°ãã«è¡ãããŸãã
ãããã®ãã¬ãŒã ã¯ãŒã¯ã¯ãæ¬è³ªçã«WebViewãšããã®WebViewã§ã¹ãã³ãããã®ãhtml + css + jsã§èšè¿°ããæ©èœãæäŸããŸãã ãããã£ãŠããã®ãœãªã¥ãŒã·ã§ã³ãæäŸã§ããã¢ããªã±ãŒã·ã§ã³èªäœã®å質ã§ãããŠãŒã¶ãŒãšã¯ã¹ããªãšã³ã¹ã¯æè¯ã§ã¯ãªãããšãç解ããŠããŸãã ãã©ãããã©ãŒã èªäœãæäŸãããã®ã§ã¯ãããŸããã
-React Nativeã¯ä»ã®ãã¬ãŒã ã¯ãŒã¯ãšã©ãéãã®ã§ããïŒ
Vladimir IvanovïŒ React Nativeã¯ãWebViewããªãã®ã§åªããŠããŸãã ãã€ãã£ãã®AndroidãiOSãããã³ãŠãããŒãµã«WindowsãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã³ã³ããŒãã³ãã䜿çšããŸãã ãã®å®è£ ã«ããããã©ãããã©ãŒã ã®èœåãæ倧éã«æŽ»çšã§ããŸããã€ã³ã¿ãŒãã§ã€ã¹ã®é床ã¯äœäžããããã€ãã£ãã«èŠããŸããããã¯ãé«å質ã®UXãæå³ããŸãã
React Nativeã¯ãReactJSããçãŸããŸãããReactJSã¯ãFacebookéçºè ãåŸæ¥ã®WebéçºããŒã«ã䜿çšããŠã¢ããªã±ãŒã·ã§ã³ããµããŒãããããšã«æµæããã£ãããã«åºçŸããŸããã ReactJSã®æ©èœã¯ãäžéã®JSXèšèªãHTMLã§ã¬ã³ããªã³ã°ã§ããããã«ããã¬ã³ãã©ãŒã¬ã€ã€ãŒã®ååšã§ããããã¯ããã©ãŠã¶ãŒã«ãã£ãŠæ¢ã«èªèãããŠããŸãã
ããæç¹ã§ãFacebookã®ã¡ã³ããŒã¯ãã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã«å¯ŸããŠãŸã£ããåãã¢ãããŒãã䜿çšã§ããããšã«æ°ä»ããŸããã Reactã¢ãŒããã¯ãã£ãŒã¯ãJSXããã€ãã£ããã©ãããã©ãŒã ã³ã³ããŒãã³ãã«å€ãããã€ãã£ãã¬ã³ãã©ãŒãè¿œå ããŸããã ãããã£ãŠã圌ãã¯React Nativeãé²åçã«åãåããŸãããæåã¯ç°åžžãªãã¬ãŒã ã¯ãŒã¯ãäœæãããšããã¿ã¹ã¯ãèªåèªèº«ã§èšå®ããã®ã§ã¯ãªããèªç¶ãªæ¹æ³ã§ããã«å°éããŸãã
-React Nativeã«ã¯ãä»®æ³DOMãªã©ããããŸãã ããã¯ãã¢ããªã±ãŒã·ã§ã³éçºãé«éåããæ¬åœã«ã¯ãŒã«ãªãœãªã¥ãŒã·ã§ã³ã§ããïŒ
ãŠã©ãžããŒã«ã»ã€ã¯ããïŒ Reactã¯ããã®ã³ã³ããŒãã³ãã®äž»ãªè·æ¥ãç¶æ ã衚瀺ããã ãã§ããããã«æ§ç¯ãããŠããŸãã ã³ã³ããŒãã³ããæã£ãŠããrenderïŒïŒã¡ãœããã¯StateãèŠãŠãããã«åºã¥ããŠã³ã³ãã³ããæç»ããŸãã ç¶æ ãå€æŽããããšãReactã¯ã³ã³ããŒãã³ãã®ããªãŒå šäœãåäœæããŸãã ãã®ããªãŒã¯ä»®æ³DOMãšåŒã°ããŸãã
ã€ãŸããç¶æ ãå€ãã£ãããããŒãžå šäœãåæç»ããå¿ èŠããããŸãã ããããããã¯ããã©ãŒãã³ã¹ã®ç¹ã§æªãã§ãã Reactã¯äœãããŸããïŒ ä»®æ³DOMã®ã³ã³ããŒãã³ãã®å€ãããªãŒãšæ°ããããªãŒãã¡ã¢ãªã«ä¿åããå·®ãèšç®ããŠãããã ããå®éã®DOMã«é©çšããŸãã ä»®æ³DOMã§ã¯å®å šãªåæç»ãè¡ãããŸãããå®éã®åæç»ã§ã¯éšåçãªåæç»ã®ã¿ã§ãã ã¬ã³ããªã³ã°ã¯éåžžã«è¿ éã«è¡ãããã³ãŒãã¯ç°¡åã«èšè¿°ãããŸãã
-React Nativeãšãã€ãã£ãéçºã§äœ¿çšãããèŠçŽ ã¯ã©ã®ããã«é¢é£ããŠããŸããïŒ
ãŠã©ãžããŒã«ã»ã€ã¯ããïŒäžéšã®èŠçŽ ã¯ãã€ãã£ãã®ãã®ã«äŒŒãŠããŸãã ããšãã°ãããã¹ãå ¥åã ããããReact Nativeã®å©ç¹ã¯ãããŒãºã«åãããŠç¬èªã®ã³ã³ããŒãã³ããäœæã§ããããšã§ãã React Nativeã®ãã€ãã£ãããŒã«ã®ã©ãããŒããã€ã§ãäœæã§ããã¯ãã¹ãã©ãããã©ãŒã ã¢ããªã±ãŒã·ã§ã³ãããããšãJavaScriptã§æ³å®ãç¶ããããšãã§ããŸãã
ããã·ã¥éç¥ãªã©ãå€ãã®ããšããã®æ¹æ³ã§æ©èœããŸãã Androidçšã®Javaã³ãŒããiOSçšã®Objective-Cã«å®è£ ãããŠãããœãªã¥ãŒã·ã§ã³ããããŸãã 次ã«ããã®NPMã¢ãžã¥ãŒã«ããããžã§ã¯ãã«æ¥ç¶ãããããã·ã¥éç¥çšã®JavaScriptã€ã³ã¿ãŒãã§ãŒã¹ããããŸãã äœãã©ãããã©ãŒã ã®ãã®ã«ã¢ã¯ã»ã¹ããå¿ èŠãããå Žåã¯ããã€ã§ãæäŸã§ããŸãã
-React Nativeã®çæã¯äœã§ããïŒ
Vladimir IvanovïŒããŸããŸãªãã©ãããã©ãŒã ã«å³ããã€ã³ã¿ãŒãã§ã€ã¹èŠä»¶ããããããŒãžã§ã³ã«ãã£ãŠå€§ããç°ãªãå Žåã¯ãUIã®ããªãã®éšåãè€è£œããå¿ èŠããããŸãã
ãã ããããžãã¹ããžãã¯ã¯ã¯ãã¹ãã©ãããã©ãŒã ã®ãŸãŸã«ããããšãã§ããŸãã ã€ãŸããç¶æ ã«å€éšã¹ãã¬ãŒãžã䜿çšããReact Nativeã«é©åãªã¢ãŒããã¯ãã£ãäœæããŠããå€ãã®åŽåãç¯çŽã§ããŸãã
ãã¡ãããReact-Nativeã¯è¥ããã¯ãããžãŒã§ãããããžã£ã ããªãã§ã¯ã§ããªãããšãå¿ããªãã§ãã ããã ããšãã°ã倧ããªããžã£ã ãã¯ããã²ãŒã·ã§ã³ã§ãã RNã¯ããã²ãŒã·ã§ã³ã®åèšèšã®4ã€ã®æ®µéïŒNavigatorãNavigatorIOSãNavigationExperimentalãªã©ïŒãæ¢ã«ééããŠãããšããäºå®ã«ããããããããŸãšããªè§£æ±ºçã¯ãããŸããã 圌ãã¯æ¬¡ã®ããã²ãŒã·ã§ã³ã¯ç¢ºãã«è¯ããã®ã«ãªããšçŽæããŠããŸããããåç¥ã®ããã«ã3幎ãæåŸ ãããŠããŸãã
-React Nativeã䜿ãå§ããããã«äœãåŠã¶å¿ èŠããããŸããïŒ
Vladimir IvanovïŒãŸããéçºè ã¯JavaScriptãšãã®ES6æšæºãç¥ãå¿ èŠããããŸãã Babelã¯ãReact.createClassãšBoilerplateã®æ®ãã®éšåãã©ãã«ã§ãæžããªãããã«ããã¹ãŠã®åãå¿ èŠãšããŸãã ãããã£ãŠãES6ãå匷ããããšããå§ãããŸãã
ãããŠãä»ã®ãã¹ãŠã®ããšã§ã人ã¯ååã«æ©ãç¥ãåãã«ãªããŸãã 1ãæ以å ã«ãè³æãèªãã§ãã€ã³ã¿ãŒãããã§ãã£ã±ãã®ãã¬ãŒãã³ã°ã³ãŒã¹ãèããåŸãå€ããå°ãªããéåžžã®UIãããã«äœãå§ããããšãã§ããŸãã
ãã¡ãããå€éšã®ç¶æ ããã©ãŒã ã®æ€èšŒãReact Nativeã§ã®ã³ã³ããã¹ãã®äœ¿çšãªã©ãè€éãªãããã¯ããããŸãã ãããã®ããšã«ã€ããŠã¯ã Mobius 2017ã§ã話ãããŸãã®ã§ããã²ãè¶ããã ããã
React NativeãåŠç¿ããã人ã¯ãFacebookã®ãã¯ããã«ããèªãã§ãã ããã Udemyã®ã³ãŒã¹ããå§ãããŸã ã ãŸããReactãæ±ãæå°è ã«æ³šç®ãã䟡å€ããããŸãã Dan Abramovã®twitterããå§ãããŸãã圌ã¯React Nativeã«ã€ããŠããããæžããŠããŸãã
ãã¡ãããã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã«è§Šããããšã®ãªãå°åããæ¥ãå Žåãç¬èªã®SDKã®ã€ã³ã¹ããŒã«ããšãã¥ã¬ãŒã¿ãŒã®åŒãäžããSDKã®ã®ã¬ãã€ãã®åºåã«é¢ãããã®æ¢æ±ãè¡ãå¿ èŠããããããã¯å€ããå°ãªããæåããã»ã¹ã§ãããšããäºå®ã«ã¯ãŸã£ããæ²ãã¿ããããŸãã ãã®çµæãã¢ãã€ã«éçºã®å°éç¥èãå¿ èŠã«ãªããŸããããã§ãªããã°ãéå§ããå¿ èŠãããããŸããã ããããã»ãã®1é±éåãReact Confã§ã圌ãã¯React Nativeã®create-react-appã®é¡äŒŒç©ã create-react-native-appãå°å ¥ããŸããã ã¢ãã€ã«éçºè ã«ãšã£ãŠãããã¯ãã¡ããã·ã§ãã¯ã§ããã¢ããªã±ãŒã·ã§ã³ã®ãªãã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã®ãããªãã®ã§ãã ããããæåã¯ãããçæ³çãªãªãã·ã§ã³ã§ããã¹ã¯ãªããããã¹ãŠãæ§æããã¬ã€ãºããŸããSDKãããŠã³ããŒãããå¿ èŠã¯ãªããé»è©±ã§ã¢ããªã±ãŒã·ã§ã³ãããã«èŠãããšãã§ããŸãã
-React Nativeã«æ¹ãããŠããã®ã¯ãªãã§ããïŒ
Vladimir IvanovïŒéçºè ãšããŠã®ãããå¹æã¯ãã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ãUIã®éçºã¢ãããŒãããŸã£ããç°ãªããšããäºå®ããç§ãå®ã£ãŠããŸããã AndroidãiOSã§ã¯ãåœä»€åããã°ã©ãã³ã°ã«çŽé¢ããŠããŸããã€ãŸãããããããã£ãŠããã¿ã³ãé ããŠãããã§ç¹æ» ã-UIã³ãã³ãã«äœããã¹ãããäžããŸãã ãŸããReact Nativeã§ã¯ãã¢ãããŒãããŸã£ããç°ãªããŸããããã«åãæ¿ããã«ã¯ãé ãå°ãå£ãå¿ èŠããããŸãã ããã¯éçºã¢ãã«ã®å®å šãªå€æŽã§ãããå¬ããæããŸããã
ãããã®ããŒã«ã¯æ¬åœã«åªããŠãããããè¿ãå°æ¥ãæ¥çå šäœããããã®ããŒã«ã«ç§»è¡ãå§ãããšæããŸãã ããã«ãReact Nativeã¯ã¯ãŒã«ãªã³ãã¥ããã£ã掻çºã«åœ¢æãããŠãããªãŒãã³ãœãŒã¹ãœãªã¥ãŒã·ã§ã³ã§ãã ããã§ãUberEatsã¯è£œåã§React Nativeã䜿çšããæ¹æ³ãå ¬éãã次ã®ããã«æžããŠããŸãã
ãŠã©ãžããŒã«ã»ã€ã¯ããã¯ã2017幎4æ21ã22æ¥ã«ãµã³ã¯ãããã«ãã«ã¯ã§éå¬ãããã¡ããŠã¹äŒè°ã§ã ãReact NativeïŒSurvival Lessonsããšããã¬ããŒãã§ãReact Nativeã§æ¬æ Œçãªåæ¥ãããžã§ã¯ããäœæããæ¹æ³ã«ã€ããŠè©±ããŸãã