- ãã©ã¦ã¶ã¯GUIã¢ããªã±ã¼ã·ã§ã³ãã©ãããã©ã¼ã ã§ã¯ãªã
- React DOMã¯GUIã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã§ã¯ãªã
- React Nativeã¯GUIã¢ããªã±ã¼ã·ã§ã³ãã©ãããã©ã¼ã ã®æ½è±¡ã§ãã
- React Native for Webããã©ã¦ã¶ã«æã¡è¾¼ãã ãã®
- ãããã¯ã·ã§ã³äºä¾ãå¼·ããã
- ä½è ã®necolasãèªã£ã¦ã
- ã¾ã¨ã
- ä½è«ï¼Reactç³»ã®ã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯
React Native for Webã¯ãReact NativeãWebã«æã¡è¾¼ã試ã¿ã§ãã
ãã°ãã°ããããã£ã試ã¿ã«å¯¾ãã¦ããããããããªãããæ¬æ«è»¢åã§ãããã¨ãã£ãæè¦ãè¦ããã¾ãããçè ã¯å¦¥å½ãªè©¦ã¿ã§ããã¨ããå°è±¡ãæã£ã¦ãã¾ããã¡ãã£ã¨é ã®ä¸ã«ãããã®ãåºãã¦ã¿ããã¨æãã¾ãã
ãã©ã¦ã¶ã¯GUIã¢ããªã±ã¼ã·ã§ã³ãã©ãããã©ã¼ã ã§ã¯ãªã
ã¾ãåæã¨ãªã£ã¦ããææ³ã¨ãã¦ã Webãã©ã¦ã¶ã¯GUIã¢ããªã±ã¼ã·ã§ã³ãã©ãããã©ã¼ã ã§ã¯ãªã ãã¨ãããã®ãããã¾ãããã©ã¦ã¶ã¯å ã ããã¥ã¡ã³ããã¥ã¼ã¢ã§ãããWebãã¼ã¸ã§æ å ±ãé²è¦§ããããã®ã½ããã¦ã§ã¢ã§ãããã¢ããªã±ã¼ã·ã§ã³ã®ã©ã³ã¿ã¤ã ã§ã¯ãªãã£ããã¨ããç«å ´ã§ãã
HTMLãCSSãJSï¼vanilla jsãï¼ãã綺éºã§ã»ãã³ãã£ãã¯ã§ã¤ã³ã¿ã©ã¯ãã£ããªWebãµã¤ããä½ãããã®é²åãéãã¾ããããå ã ãããã¥ã¡ã³ããã¥ã¼ã¢ãªã®ã§ãã¢ããªãåããããã®ãã¬ã¼ã ã¯ã¼ã¯ã¨ãã¦ã¯ç¡çãæ®ãã¾ãã
巨大ãªé åãã¼ã¿ã®ãªã¹ããçã¡ã¢ãªã§è¡¨ç¤ºã§ããä»çµã¿ãã¦ã¼ã¶ã¼ã®è¨èªãå°åã®è¨å®ã«åããã¦èªåã§è¡¨ç¤ºè¨èªãåãæ¿ããæ©è½ãªã©ãAndroidãiOSã§ããã°å½ç¶æã£ã¦ããæ©è½ã¯ãã©ã¦ã¶ã«ã¯æè¼ããã¦ãã¾ããããã¦ã³ãã¼ãå¦çãéåæå¦çãä¼´ããªãã°ãã²ä½¿ãããããã°ã¬ã¹ãã¼ããã¤ã³ã¸ã±ã¼ã¿ï¼ããããï¼ããæ¨æºã§ã¯æè¼ããã¦ãã¾ããã
ãã©ã¦ã¶ã§åããããªãã¨ããããã¨æã£ããã人æ°ã£ã½ãJavaScriptã©ã¤ãã©ãªãCSSãã¬ã¼ã ã¯ã¼ã¯ãé¸å®ããå°å ¥ããå¿ è¦ãããã¾ããããã¯ãããã¥ã¡ã³ããã¥ã¼ã¢ãé å¼µã£ã¦GUIã¢ããªã±ã¼ã·ã§ã³ã£ã½ãåããããã®ä½æ¥ãã§ããé å¼µãã®å¤§åãã©ã¤ãã©ãªè£½ä½è ãæ ã£ã¦ããã¦ããããã«å®æãã¥ããã§ãããçè ã¯ããæã£ã¦ãã¾ãã
ããã¯ãã©ã¦ã¶ãGUIã¢ããªã±ã¼ã·ã§ã³ãã©ãããã©ã¼ã ã¨ãã¦å£ã£ã¦ããã¨ãã話ããããã®ã§ã¯ãªããããããããã¥ã¡ã³ããã¥ã¼ã¢ãªã®ã§ãGUIã¢ããªã±ã¼ã·ã§ã³ãä½ãã¥ããã®ã¯èªç¶ãªãã¨ã§ãããã¨ãã話ã§ããdivãspanãul/liããããããè£ é£¾ããCSSããGUIã®ã¬ã¤ã¢ã¦ããçµããã¨ã«ç¹åããä½ãããã¦ããããã§ã¯ãªãã®ã§ãã
Flexboxã«ã¤ãã¦
ã¡ãã£ã¨ä¸»å¼µããã¬ãããã«æãããããããã¾ããããFlexboxã¯ã¢ããªéçºã«åãã¦ãããªããã¨æã£ã¦ãã¾ããWebãµã¤ããä½ã£ã¦ããä¸ã§ãå½¹ç«ã¤ã®ã§ãå¥ã«ã¢ããªéçºã®ããã«ä½ãããæ©è½ã¨ããããã§ããªãã¨æãã®ã§ãããAndroidã®LinearLayoutãiOSã®StackViewãªã©ãé¡ä¼¼ã®æ©è½ãã¢ããªéçºã®ç¾å ´ã§ã¯æ¬ ãããªãç¶æ³ã«ãªã£ã¦ããã®ã§ããããç»å ´ããã¨ãã«ã¯æ¬å½ã«å¬ããã£ãã»ã»ã»
React DOMã¯GUIã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã§ã¯ãªã
ãã©ã¦ã¶ãã®ãã®ãGUIã¢ããªã±ã¼ã·ã§ã³ãã©ãããã©ã¼ã ã§ãªãã®ã§ããã°ãä½ããã®ãã¬ã¼ã ã¯ã¼ã¯ãåã¾ãããã¨ã§ãããç¨åº¦GUIã¢ããªã±ã¼ã·ã§ã³ãä½ãããããªãããã§ããããçè ã¯ãã°ããã®éããReact DOMã使ã£ãããã©ã¦ã¶ãGUIã¢ããªã±ã¼ã·ã§ã³ãã©ãããã©ã¼ã ã§ãããã®ããã«æ±ãããã¨æã£ã¦ãã¾ããã
ãã¦ãç¾å®ãè¦ã¦ã¿ã¾ãããã
Reactã¯ãDOMãããããã®åä½ã§åãåããã³ã³ãã¼ãã³ãã¨ãã¦æ±ããã¦ããã¾ããReactã¯ããã¼ã¿ã®æ´æ°ã«å¯¾ããDOMã®æ´æ°ãæä½éã«æãã¦ããã¾ããReactã®ãããã§ãè¤éãªã¤ã³ã¿ã©ã¯ã·ã§ã³ãæä½éã®ã³ã¹ãã§ç®¡çã§ããããã«ãªãã¾ããã
ããã§ãã©ããªè¤éãªWebãµã¤ãã§ãæ§ç¯ã§ãã¾ãï¼
â¦â¦â¦â¦â¦â¦â¦â¦â¦â¦
â¦â¦â¦â¦â¦â¦â¦â¦
â¦â¦â¦â¦
â¦â¦ãã£ã±ãGUIã¢ããªã±ã¼ã·ã§ã³ã®ãã¬ã¼ã ã¯ã¼ã¯ã¨ããæãã§ã¯ãªããâ¦â¦ï¼
ãããã¥ã¡ã³ããã¥ã¼ã¢ãé å¼µã£ã¦GUIã¢ããªã±ã¼ã·ã§ã³ã£ã½ãåãããããã®ã³ã¹ããä¸ãã¦ãããåå¨ã§ãããã¨ã¯ééããªãã®ã§ãããã¬ã¤ã¢ã¦ããçµãããã«å¿ è¦ãªé å¼µãã®æ¹åæ§ã¯ã楽ã«ãªã£ãã ãã§ï¼ããã¯ããã§ãã¡ããéè¦ãªãã§ããï¼ããã¾ãå¤ãã£ã¦ãã¾ããã
React Nativeã¯GUIã¢ããªã±ã¼ã·ã§ã³ãã©ãããã©ã¼ã ã®æ½è±¡ã§ãã
AndroidãiOSã¯GUIã¢ããªã±ã¼ã·ã§ã³ãã©ãããã©ã¼ã ã§ããReact Nativeã¯ä¸¡è ã®ä¸ã§GUIã¢ããªã±ã¼ã·ã§ã³ãæ§ç¯ãããããã®ãã¼ã«ãç¨æããã«ããããAndroidãiOSã«ãã£ããã®ãå ±éåããå½¢ã§ãGUIã¢ããªã±ã¼ã·ã§ã³ãä½ããªã大æµããããã®ãå¿ è¦ã§ãããã¨ããã³ã³ãã¼ãã³ã群ãã¢ã¸ã¥ã¼ã«ç¾¤ãç¨æãã¾ããã
ç¹ã«ã³ã³ãã¼ãã³ã群ã«ã¯å¬ãããã®ãå¤ãã§ããåºæ¬ã¨ãªãViewãText以å¤ã«ãããããããåºãã¦ãããActivityIndicatorãã巨大ãªé åãã¼ã¿ãçã¡ã¢ãªã§ãªã¹ã表示ã§ããFlatListãæãã°ã¹ã¯ãã¼ã«ããã¦ãããScrollViewãé²æã表示ããProgressBar/ProgressViewãå¼ã£å¼µã£ã¦æ´æ°ã®RefreshControlãªã©ã ãç¡ããç¡ãã§ã©ãããã調éãã¦ãããªãèªä½ãªããããã©ããããªãå¬ããã ãæã£ã¦ãã¾ãããã¡ãã足ããªããã®ãããã®ã§èªä½ãããã¨ãããã¾ãããGUIã¢ããªã±ã¼ã·ã§ã³ãæ§ç¯ãã¦ããã«ããã£ã¦ã®æä½éã®ãã¼ã¹ã¨ãã¦ã¯å å®ãã¦ããã¨æãã¾ãã
ãã®æ½è±¡ã¯Android/iOSããã¼ã¹ã«çã¿åºãããã®ã§ãAndroidã¨iOSã§ããæå¹ã§ãªããã®ã¨æãããã¡ã§ãããå®éã«ã¯ãã©ãããã©ã¼ã ãéå®ããªãæ½è±¡åãè¡ã£ã¦ãããããreact-native-windowsãreact-native-macosã¨ãã£ããä»ã®ãã©ãããã©ã¼ã ã®æ½è±¡åã«ãæåãã¦ãã¾ãã
React Nativeã¯ãããããGUIã¢ããªã±ã¼ã·ã§ã³ãã©ãããã©ã¼ã ãæ½è±¡åãããã¬ã¼ã ã¯ã¼ã¯ã§ãããã¨è¨ããã®ã§ã¯ãªããã¨ãããçè ã¯æãã¦ãã¾ãã
React Native for Webããã©ã¦ã¶ã«æã¡è¾¼ãã ãã®
Webãã©ã¦ã¶ä¸ã§GUIã¢ããªã±ã¼ã·ã§ã³ãæ§ç¯ãããã¨ããå ´åã«ããReact Nativeã®ãGUIã¢ããªã±ã¼ã·ã§ã³ãä½ããªã大æµããããã®ãå¿ è¦ã§ãããã¨ããã³ã³ãã¼ãã³ãã®ã©ã¤ã³ãããã¯ããã¯ãæå¹ã§ãã
React Native for Webã¯ããã¤ãã£ãã¢ããªããã©ã¦ã¶ä¸ã§åç¾ãããã¨ãããã®ã§ã¯ããã¾ãããReact Nativeãæå±ããGUIã®æ½è±¡åããWebã¢ããªã±ã¼ã·ã§ã³ã®ä¸çã§ã使ããããã«ããããã©ã¦ã¶åãã®Reactã³ã³ãã¼ãã³ãï¼ä¾¿å©ã¢ã¸ã¥ã¼ã«éã©ã¤ãã©ãªã§ãã
React Nativeæ¬å®¶ã®ãã¯ããã¸ã¹ã¿ãã¯ã¨ã¯ç°ãªãã次ã®å³ã®ãããªæ§æã«ãªã£ã¦ãã¾ãã
ãã¾ãã¾React Nativeã¨ä¼¼ããããªã©ã¤ã³ãããã®ã³ã³ãã¼ãã³ããããã¾ãã¾ä¼¼ããããªååã®propsãæã£ã¦ãã¦ããã¾ãã¾React Nativeã¨ä¼¼ããããªã¹ã¿ã¤ã«ãæã£ã¦ããããã ããã ãã§ããã¹ã¿ã¤ã«ãpropsã«é¢ããææ³ãReact Nativeã«å¯ãã¦ããã ãã§ãã©ã¤ãã©ãªã¨ãã¦ã¯material-uiãOnsen UIã«è¿ãã¨ãããããã§ãããã
ã³ã³ãã¼ãã³ãã便å©
ã¨ããããã§ããã ã®ãã©ã¦ã¶åãReactã³ã³ãã¼ãã³ãã¨ãã¦ã¿ãå ´åã«ãã©ããªã³ã³ãã¼ãã³ãããããã¨ããã¨ã
- ãããããåºãã¦ãããActivityIndicator
- æãã°ã¹ã¯ãã¼ã«ããã¦ãããScrollView
- é²æã表示ããProgressBar
- å¼ã£å¼µã£ã¦æ´æ°ã®RefreshControl
ããããã®ãæ®éã«ä½¿ããããã§ãã便å©ã§ããã
ã¹ã¿ã¤ã«å¨ããè¯ãæã
GUIã¢ããªã±ã¼ã·ã§ã³ãç¹ã«ã¢ãã¤ã«ã§ã®åä½ãæèããã¹ã¿ã¤ã«ãæåããå¹ãã¦ãã¾ãã
ä¾ãã°ScrollViewã«ã¯æ¬¡ã®ãããªç¹æ§ãããã¾ãã
- ç´°ããè¨å®ãããªãã¦ãScrollViewã®ä¸ã«ã¯æ £æ§ãå¹ã
- ç´°ããè¨å®ãããªãã¦ãScrollViewã®ä¸èº«ããªã¼ãã¼ã¹ã¯ãã¼ã«ãã
ä¾ãã°ããããã®âãæ¸ããã ãã§ãç»åã縦ã«ãºã©ãã¨ä¸¦ãã§ãæ £æ§ã¹ã¯ãã¼ã«ãè´ãã¦ãä¸çªä¸ã¾ã§è¡ã£ããã¡ãã£ã¨ãªã¼ãã¼ã¹ã¯ãã¼ã«ãããã¦ãããããã§ãã
<View> <ScrollView style={{flex:1}}> <Image /> <Image /> <Image /> ... </ScrollView> <Text>ç»é¢ä¸é¨ã«åºå®ã®ããã¹ã</Text> </View>
ãã®ã¸ãã¯Mobile Safariã«è¦ããããããã¨ããã£ãã®ã§ãå°å³ã«å¬ããã§ãã
ã¾ããReact Nativeã§ã¯ã¬ã¤ã¢ã¦ãã«Flexboxãæ¡ç¨ãã¦ããã®ãè¸è¥²ãã¦ã次ã®ãããªç¹æ§ãæã£ã¦ãã¾ãã
- 常ã«
display: flex
ãå¹ãã¦ã flexDirection
ã®ããã©ã«ãå¤ãcolumn
ï¼ç¸¦ä¸¦ã³ï¼
æ¯å display: flex
ãæ¸ããªãã¦ããã®ã¯å®å
¨ã«æ¥½ã§ãããã¢ãã¤ã«åãã®ã¢ããªã§ã¯ã¢ã¤ãã ãä¸ããä¸ã«ä¸¦ã¹ããã¨ãå¤ããã¨ãããflexDirectionãæå®ããæ©ä¼ãæ¸ãã®ãå©ããã¾ãã
TouchableOpacityã§ã¿ãã表ç¾ãã©ã¯ã©ã¯
TouchableOpacityã¯ãã¿ããã¤ãã³ãã«å¿ãã¦å²ãã å å´ã®Viewã®éæ度ãå¤ãããã£ã¼ãããã¯ã表ç¾ãããããã®ã³ã³ãã¼ãã³ãã§ãã
<TouchableOpacity onPress={() => { /* ã¿ããã¤ãã³ã */}}> <View /> // èªä½ã®ãã¿ã³ã£ã½ããã® </TouchableOpacity>
ä¸è¨ã®ãããªã³ã³ãã¼ãã³ããä½ã£ãå ´åãå å´ã®Viewã«ã¯ä¸åã¿ããã¤ãã³ãã«é¢ããè¨å®ãè¡ããªãã¦ããç°¡åãªãã£ã¼ãããã¯ãå®è£ ãããã¨ãã§ãã¾ãã
ä»ã«ããããããããã©
GUIã¢ããªã±ã¼ã·ã§ã³ãä½ãéã«ä¾¿å©ãªãããããè©°ã¾ã£ã¦ãã¾ãã
React Nativeæ¬å®¶ã¨ã³ã¼ãã®å ±éåãã¿ãããªæèããªãããã§ã¯ãªãã§ãããããããããåç´ã«Webã¢ããªéçºã便å©ã«ãã¦ããããã¼ã«ã ã¨æã£ãã»ããæ°æ¥½ã«è©¦ããã¨æãã¾ãã
触ã£ã¦ã¿ãããªã£ãæ¹åãã«ãcreate-react-appä¸ã«React Native for Webç°å¢ãç½®ãããã¤ã©ã¼ãã¬ã¼ããç¨æãã¦ãããã®ã§ã触ã£ã¦ã¿ã¦ãã ããã
ãããã¯ã·ã§ã³äºä¾ãå¼·ããã
å®ã¯ãPWAã®äºä¾ã¨ãã¦æåãªTwitter Liteã¯ãReact Native for Webã®äºä¾ã§ãããã¾ãã
If you use Twitter Lite you're now using a web app rendered by React Native for Web
— Nicolas (@necolas) September 29, 2017
Twitter Liteã¯React Nativeã«ãããã¤ãã£ãã¢ããªçãåå¨ããããã§ããªããç´ç¶ããWebã¢ããªã§ãã
ãããã£ãæ´»ç¨ãã§ããç¨åº¦ã«ã¯ãReact Native for Webã¯Webã¢ããªéçºã®æèã§æç¨ãªãã®ã§ããã¨çè ã¯èãã¾ãã
ä½è ã®necolasãèªã£ã¦ã
https://twitter.com/necolas/status/983769332411805697
âããå§ã¾ãä¸é£ã®ãã¤ã¼ãã§ãReact Nativeãã®ãã®ãfor Webã®å¯è½æ§ã«ã¤ãã¦èªã£ã¦ãã¾ããã¢ããã§ãã
ã¾ã¨ã
React Native for Webã¯ãReact Nativeã«ãã£ã¦æ½è±¡åããããã¢ãã¤ã«ã¢ããªéçºã®å½ããåãããã©ã¦ã¶ã®ä¸çã«æã¡è¾¼ãã§ãããåå¨ã§ãã
åç´ã«Webã¢ããªéçºã®è² æ ã軽æ¸ãã¦ãããã¨ãããããã¾ããããã¤ãã£ãã¢ããªéçºã®åºèº«è ãåãã¦Webã¢ããªéçºã«æºãã£ãã¨ãã«çµé¨ããããããã£ããããªãã¨ãèªåã§å·¥å¤«ããªãã¨ãããªãã®ããããããã軽æ¸ãã¦ãããå¹æãæå¾ ã§ãã¾ãã
ScrollViewãªã©ãåç¬ã§ä½¿ããã¨ãã§ããã®ã§ãçããã®Webã¢ããªã®ä¸é¨ã«åãè¾¼ãã§ã¿ã¦ã¯ãããã§ããããã
ä½è«ï¼Reactç³»ã®ã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯
Reactãã¼ã¹ã§ãããªããã¾ã£ããå¥ã®ã³ã¼ããã¼ã¹ã§éçºãé²ãããã¦ãããã¬ã¼ã ã¯ã¼ã¯ãã¡ãæãã¦ã¿ã¾ãã
- React Native
- Android, iOSåãã®GUIã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯
- ãã¤ãã£ãå®è£
é¨åãå·®ãæ¿ããã ãã®ãµã¼ããã¼ãã£å®è£
ããã
- react-native-windowsï¼Windowsï¼
- react-native-macosï¼macOSï¼
- react-native-domï¼ãã©ã¦ã¶ï¼
- ãã®è¾ºã®è©±ã¯å æ¥ã®è¨äºã詳ãã
- React Native for Web + React DOM
- ãã©ã¦ã¶åãã®GUIã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯
- React Nativeã®ã³ã³ãã¼ãã³ãã模å£ãã¦ãã
- React 360
- VRã¢ããªã®ããã®GUIã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯
- React Nativeã®ã³ã³ãã¼ãã³ãã模å£ãã¦ãã
- Ink
- ã¿ã¼ããã«ã®ããã®CLIã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯
- ç¬èªã®çæ ç³»ãæ§ç¯ãã¦ãã
ã¯ããInkããªãã«ä½¿ãããã£ãã ãã§ãã
<Color green> {this.state.i} tests passed </Color>
å®å ¨ã«ç¬èªã®çæ ç³»ã§ããã»ã»ã»ãã®çºæ³ã¯ãªãã£ãã»ã»ã»