ããã«ã¡ã¯ã12æã«å ¥ã£ã¦ãã¡ãã¡ã§ã¢ããã³ãã«ã¬ã³ãã¼ãå§ã¾ã£ã¦ãã¾ãããä»å¹´ã¯ã©ãããããåæ¥ã¾ã§è¿·ã£ã¦ããã®ã§ãããä»å¹´ã¯Reactã使ã£ã¦ããã³ãã¨ã³ãéçºãå§ããã®ã§ãå人çãªæ¯ãè¿ããå ¼ãã¦ããããReactãå§ããæ¹åãã«è¨äºãæ¸ãã¾ãã
Reactã¨ã¯
Meta(æ§Facebook)ã¨ã³ãã¥ããã£ã«ãã£ã¦éçºããã¦ããUIæ§ç¯ã®ããã®JavaScriptã©ã¤ãã©ãªã§ããReact.jsãReactJSã¨å¼ã°ãããã¨ãããã¾ãããReactã¨ããååã®ã¿ã§å¼ã°ãããã¨ãå¤ãã§ãã Reactã¯å ã Facebookã®News Feedã®UIãæ§ç¯ããããã«éçºããããã®ã§ããã®å¾2013å¹´5æã«ãªã¼ãã³ã½ã¼ã¹åããã¾ãããç¾å¨ã§ã¯æ§ã ãªãµã¼ãã¹ã§ä½¿ç¨ããã¦ãã¾ãã
Reactã®ç¹å¾´
Reactã®ç¹å¾´ã¯ä»¥ä¸ã®éãã§ãã
- 宣è¨çãªView
- ã³ã³ãã¼ãã³ãå¿åã®UIæ§ç¯
- å¹ççãªã¬ã³ããªã³ã°
Next.jsã¨ã¯
Next.jsã¯Reactã使ã£ãã¢ããªã±ã¼ã·ã§ã³ãä½æããããã®ãã¬ã¼ã ã¯ã¼ã¯ã§ããã¯ã©ã¤ã¢ã³ããµã¤ãã§ã¬ã³ããªã³ã°ããReactã«å¯¾ãã¦ãNext.jsã§ã¯ãµã¼ããµã¤ãã¬ã³ããªã³ã°ã«ã対å¿ãã¦ãã¾ããNext.jsã¯Reactã«æ¯ã¹ã¦æ¯è¼çæ´å²ãæµ ããã¬ã¼ã ã¯ã¼ã¯ã§ãããReactãããéçºãã¹ã ã¼ãºã«é²ããããã®ä»çµã¿ãæ´ã£ã¦ãã¾ããæè¿ã§ã¯Next.jsã使ã£ãããã³ãã¨ã³ãéçºã主æµã«ãªãã¤ã¤ããã¾ãã
æºå
å®è¡ç°å¢
Reactãå§ããã«ã¯Node.jsãå¿ è¦ã§ãããä½ããå§ãããã¨ããã¨ããããç°å¢æ§ç¯ã¯åãã¦ä½ãããããã¨ããã¨ãã«ã¯æåã®é¢éã«ãªãã¾ããä»åã¯ãVisual Studio Codeã®Dev Containersæ©è½ã使ã£ãå®è¡ç°å¢ã®æ§ç¯ãç´¹ä»ãã¾ãã Dev Containersã使ãã«ã¯Visual Studio CodeãDockerãå¿ è¦ã§ãããã¤ã³ã¹ãã¼ã«æ¹æ³ãªã©ã®ç´°ãã説æã¯çç¥ããã¦ããã ãã¾ããããããã®ã¤ã³ã¹ãã¼ã«æ¹æ³ã¯ä»¥ä¸ã®ãªã³ã¯ããå ¬å¼ãµã¤ãã®ããã¥ã¡ã³ããåç §ãã¦ããã ãããä»ã®ããã°è¨äºãªã©ãåèã«ãã¦ãã ããã
ã«ã¼ããã£ã¬ã¯ããªã®ä½æ
éçºã«ä½¿ç¨ããã«ã¼ããã£ã¬ã¯ããªãä½æãã¦ãã ãããç¹ã«æ±ºã¾ãã¯ããã¾ããã®ã§ã好ããªå ´æã«ä½æãã¦åé¡ããã¾ãããç¹ã«æ±ºã¾ã£ã¦ããå ´æããªãå ´åã¯ãDocumentsãã£ã¬ã¯ããªã«ä½æããæ¹æ³ãä¾ã«ãç´¹ä»ãã¾ãã æå¾ã«Visual Studio Codeãèµ·åãã¦ãå ã»ã©ä½æãããã£ã¬ã¯ããªãéãã¦ãã ããã
mkdir -p ~/Documents/dev/react-sample cd ~/Documents/dev/react-sample code .
Dev Containersã®è¨å®
Visual Studio Codeã®æ¡å¼µæ©è½ããRemote Developmentãã¤ã³ã¹ãã¼ã«ãã¦ãã ããã
Remote Development - Visual Studio Marketplace
ã¤ã³ã¹ãã¼ã«ãå®äºããã¨ã¢ã¯ãã£ããã£ãµã¤ããã¼ã«ãã®ãããªã¢ã¤ã³ã³ã表示ããã¾ãã
ã¢ã¤ã³ã³ãåé¡ãªã表示ããã¦ããæ¹ã¯ãã¯ãªãã¯ãã¦ãã ããã
ãµã¤ããã¼ã表示ããã¦ããå ´åã¯ããã®ãããªç»é¢ã«ãªãã¾ãã
ç»é¢ã表示ãããæã«ä¸é¨ã«ãããªã¹ããã¦ã³ã§éçºã³ã³ãã
ãé¸æããã¦ãããã¨ã確èªãã¦ãã ããã
次ã«å³ä¸ã«ãã+
ãã¯ãªãã¯ãã¦ãã ãããç»é¢ä¸é¨ã®ä¸å¤®ã«ãã¤ã¢ãã°ã表示ãããããã³ã³ããã¼ã§ç¾å¨ã®ãã©ã«ãã¼ãéã
ãé¸æãã¦ãã ããã
éçºç°å¢ãæ§ç¯ãããã¾ã§ã«ããã¤ã質åã«çããå¿ è¦ããã®ã§ãä»åã¯æ¬¡ã®ããã«åçãã¦ãã¾ãã
Node.js & TypeScript
ãé¸æãã¾ãã
è¦å®å¤ã®ã¾ã¾ã§ã¨ã³ã¿ã¼ãæ¼ãã¾ãã
éçºã³ã³ããã¼å ã§æ§ã ãªæ©è½ãæå¹åã§ãã便å©ãªæ©è½ã§ãããä»åã¯ä½¿ç¨ãã¾ããããã®ã¾ã¾ã¨ã³ã¿ã¼ãæ¼ãã¦ãã ããã
ãã°ããå¾ ã¤ã¨éçºç°å¢ãèµ·åããã¾ããèµ·åãå®äºããã¨å³ä¸ã«ç»åã®ãããªè¡¨ç¤ºãããã¾ãã
念ã®çºãã¿ã¼ããã«ãéãã¦node -v
ã¨npm -v
ãå
¥åãã¦ãã ããããã¼ã¸ã§ã³ã表示ãããã°æ£å¸¸ã«èµ·åãã¦ãã¾ãã
Reactã®ã¤ã³ã¹ãã¼ã«
ããã¾ã§ã§éçºç°å¢ã®æ§ç¯ãå®äºãã¾ããã次ã«Reactã®æºåããã¾ããReactã«ã¯ä¾¿å©ãªã³ãã³ããç¨æããã¦ãã¾ãã®ã§ãããã使ã£ã¦ããã¸ã§ã¯ããä½æãã¾ãã
npx create-next-app@latest src
ã¢ããªã±ã¼ã·ã§ã³ã®å®è¡
Node.jsã使ã£ãã¢ããªã±ã¼ã·ã§ã³ã®å®è¡æ¹æ³ã¯ããã¤ãããã¾ãããpackage.jsonã«ã¹ã¯ãªãããã¾ã¨ãã¦ãããå®è¡ããæ¹æ³ãä¸è¬çã§ããä»åä½æããããã¸ã§ã¯ãã§ãpackage.jsonã«ã¹ã¯ãªãããç¨æããã¦ãã¾ãã
ä»åã¯éçºç°å¢ã¨ãã¦å®è¡ããããã以ä¸ã®ã³ãã³ããå®è¡ãã¾ãã
cd src/ npm run dev
ã¢ããªã±ã¼ã·ã§ã³ãåé¡ãªãèµ·åãããããã®ãããªç»é¢ã表示ããã¾ãã
ãããã«
ããã¾ã§ã§Reactã使ã£ãã¢ããªã±ã¼ã·ã§ã³ã®éçºç°å¢ãæ§ç¯ã§ãã¾ããã次åããReactã使ã£ã¦ç°¡åãªã¢ããªã±ã¼ã·ã§ã³ãä½æãã¦ããã¾ãã