éçšäž»ã¯ãã»ãšãã©ã®åéãæãã«å®è¡ããã ãã§æåŠããŸããããã¯å°ããã£ããã§ãããïŒã§ãããã圌ãããªãããå¿ èŠãªç¥èãšã¹ãã«ãããã«èŠãããšãéåžžã«éèŠã§ããç¹ã«åéã«ã€ããŠèªæ ¢ããããšãäœããªãå Žåã¯ãä»ãã¢ããã°ã¬ãŒãããé©åãªææã§ããæ°ããã¹ãã«ãåŠã¶ããã«å€§åŠã«è¡ãå¿ èŠã¯ãããŸãããæ£ããæ¹åã«é²ãã ãã§ãããããéžè±ããããšã¯ãããŸããã
ããšãã°ãReactJSã®æ¹æ³ãç¥ã£ãŠããå Žåãããã«ãããããéèŠã®é«ãã¹ãã·ã£ãªã¹ãã«ãªãããšãã§ããŸããåå¿è ã®Webéçºè ã§ãJavaScriptãšHTMLããã§ã«ç¥ã£ãŠããå Žåã¯ãReactJSã次ã®ã¹ãããã§ãã
ãã®èšäºã§ã¯ãåªããJavaScriptéçºè ã«ãªããReactã䜿çšããããã«åŠã¶äŸ¡å€ã®ããããŒã«ãšã©ã€ãã©ãªã®ãªã¹ããå ±æããŸãã
Reactãšã¯äœã§ããïŒãªããããåŠã¶äŸ¡å€ãããã®ã§ããïŒ
Reactã¯ãFacebookã2013幎5æã«å±éããïŒãããŠåŒãç¶ããµããŒãããïŒãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹éçºçšã®jsã©ã€ãã©ãªã§ãã JavaScriptã§åçãªãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ãäœæã§ããŸãã
Reactã¯äžã®äžã§æã匷åãªjsã©ã€ãã©ãªã®1ã€ã§ããããããããåŠã¶ããšã§å€ãã®è¯ãããšãã§ããŸãã Reactã¯ãéçºè ã®AmazonãPayPalãBBCãCNNãããã³ãã®ä»ã®å€ãã®å€§æãã¯ãããžãŒäŒæ¥ã«ãã£ãŠäœ¿çšãããŠããŸããããã«ãã©ã€ãã©ãªã¯ããããããŒãºãæºããã®ã«ååãªæè»æ§ãåããŠããŸãããæ°ã«å ¥ãã®ããã¯ã¹ã¿ãã¯ãšçµã¿åãããŠäœ¿çšââã§ããŸãã Reactã䜿çšããŠãããŒã¿ããã·ã¥ããŒããã¡ãã»ãŒãžã³ã°ã¢ããªããœãŒã·ã£ã«ãããã¯ãŒãã³ã°ã¢ããªãåäžããŒãžã®Webã¢ããªãããã³å人ã®ããã°ãäœæã§ããŸãã
å®éã®ãããžã§ã¯ãã«åãçµãã§ãããšãã«Reactãç¿åŸã§ããã°ãããã«åŠã¶ããšãã§ããã ãã§ãªããæœåšçãªéçšäž»ã«èªæ ¢ããæ©äŒãåŸãããŸãã
1.npm
ãã®ããŒã«ã誰ã«ãšã£ãŠãå瀺ã§ã¯ãªãããšã¯æããã§ããç§ã¯åœŒãç¡èŠã§ããªãã£ãã
JavaScriptïŒReactã©ã€ãã©ãªãå«ãïŒã䜿çšããã«ã¯ãããŒãããã±ãŒãžãããŒãžã£ãŒïŒnpmïŒãã€ã³ã¹ããŒã«ããå¿ èŠããããŸããLinuxãã£ã¹ããªãã¥ãŒã·ã§ã³ïŒãŸãã¯Chocolatey forWindowsãŸãã¯Homebrewfor macOSïŒã«ä»å±ã®ããã±ãŒãžãããŒãžã£ãŒãšåæ§ã«ãnpmã¯ããœãããŠã§ã¢ãªããžããªã«ã¯ãšãªãå®è¡ããReactJSã³ã³ããŒãã³ããå«ãå¿ èŠãªããã±ãŒãžãã€ã³ã¹ããŒã«ããã³ãã³ããæäŸããŸãã
Linuxãã£ã¹ããªãã¥ãŒã·ã§ã³ã®ãªããžããªããNode.jsïŒããã³ããã«äŒŽãnpmïŒãã€ã³ã¹ããŒã«ã§ããŸãã
FedoraãŸãã¯RedHat Enterprise Linuxã§ã¯ã次ã®ããã«ããŸãã
$ sudo dnf install nodejs
UbuntuãŸãã¯Debianã§ã¯ããããã«ç°ãªããŸãã
$ sudo apt install nodejs npm
npmããã£ã¹ããªãã¥ãŒã·ã§ã³ã®ãªããžããªã«å«ãŸããŠããªãå Žåã¯ãNodejs.orgã«ã¢ã¯ã»ã¹ããŠããã®å Žåã®Node.jsãšnpmã®ã€ã³ã¹ããŒã«æ¹æ³ã確èªããŠãã ããã
2.ã¯ã€ãã¯ã¹ã¿ãŒã
Create React Appã¯ãReactã¢ããªã±ãŒã·ã§ã³ããã°ããäœæããããã®ãã³ãã¬ãŒããããžã§ã¯ãã§ãã Reactã§äœæ¥ãããžã§ã¯ããèšå®ããããšã¯ã以åã¯éå±ãªäœæ¥ã§ããããã ãããã®ããŒã«ã䜿çšãããšãããã³ããšã³ããã«ããã€ãã©ã€ã³ããããžã§ã¯ãæ§é ãç°å¢ãããã³ã¢ããªã±ãŒã·ã§ã³ã®æé©åãæ°ç§ã§ãŒãæ§æã«èšå®ã§ããŸããããªãã¯1ã€ã®ã³ãã³ãã§ãããè¡ãããšãã§ããŸããããã«ãããè€éãªæ§æãå¿ èŠãªå Žåã¯ãCreate React AppããæœåºãããŠããã®æ§æãã¡ã€ã«ãçŽæ¥ç·šéã§ããŸãã
Create React Appã¯ãMITã©ã€ã»ã³ã¹ã®äžã§ãªãŒãã³ãœãŒã¹ã§é åžãããŠããŸãããã®ãœãŒã¹ã³ãŒãã¯GitHubãªããžããªã«ãããŸãã
ã€ã³ã¹ããŒã«ïŒ
npm start
npm init react-app my-app
ããªãã䜿çšãããäœæããã«ã¯ãã¢ããªãåå¿ããªãå Žåã«åããŠãããªããèŠãããšãã§ãããã€ã©ãŒãã¬ãŒãã«åå¿ããã¹ãªã³ã°ã·ã§ããã«åå¿ããŸããã©ã¡ããMITã©ã€ã»ã³ã¹ã®äžã§ãªãŒãã³ãœãŒã¹ã§ãã
3.åå¿èŠå
React Sightã¯ãã¢ããªã±ãŒã·ã§ã³ãã³ã³ããŒãã³ãã®éå±€ããªãŒïŒãããŒãã£ãŒããªã©ïŒãšããŠè¡šç€ºã§ãã人æ°ã®ããèŠèŠåããŒã«ã§ããChromeæ¡åŒµæ©èœãšããŠæ¥ç¶ã§ããŸãïŒã¢ããªã±ãŒã·ã§ã³ã«é¢ããæ å ±ã衚瀺ããã«ã¯ãreact devtoolsãå¿ èŠã§ãïŒããã®ã€ã³ã¿ãŒãã§ãŒã¹ã䜿çšããŠããã£ã«ã¿ãŒãè¿œå ããŠãæã察話ããå¿ èŠã®ããã³ã³ããŒãã³ãã«çŠç¹ãåãããããšãã§ããŸããããŒãã«ã«ãŒãœã«ãåããããšãã³ã³ããŒãã³ãã®çŸåšã®ç¶æ ãšå°éå ·ã«é¢ããæ å ±ã衚瀺ãããŸããReact Sightã¯ã倧èŠæš¡ã§è€éãªãããžã§ã¯ãã®ãããã°ã«éåžžã«åœ¹ç«ã¡ãŸãã
React Sightã¯MITã©ã€ã»ã³ã¹ã®äžã§ãªãªãŒã¹ãããŠããã GitHubãªããžããªã§ãã®ãœãŒã¹ã³ãŒãã«ã¢ã¯ã»ã¹ã§ããŸããChromeWebã¹ãã¢ã䜿çšããŠã€ã³ã¹ããŒã«ã§ããŸãã
4.åå¿ãã«
React Belleã¯ãåå©çšå¯èœãªã³ã³ããŒãã³ãïŒToggleãRatingãDatePickerãButtonãCardãSelectãªã©ïŒãå«ãã«ã¹ã¿ã Reactã©ã€ãã©ãªã§ãã䟿å©ãªãŠãŒã¶ãŒãšã¯ã¹ããªãšã³ã¹ãæäŸããããã«èšèšãããŠããŸããã³ã³ããŒãã³ãã¯ãã¢ãã€ã«ããã³ãã¹ã¯ãããçšã«æé©åãããŠããŸãããããã¯é«åºŠã«ã«ã¹ã¿ãã€ãºå¯èœã§ãããé害ãæã€äººã ã®ããã®ã¢ã¯ã»ã·ããªãã£åºæºïŒWAI-ARIAïŒããµããŒãããŠããŸããã©ã€ãã©ãªã¯ãBelleãBootstrapãªã©ã®ããŸããŸãªããŒãããµããŒãããŠããŸãã
Belleã¯MITã©ã€ã»ã³ã¹ã®äžã§ãªãªãŒã¹ãããŠããã GitHubãªããžããªã§ãã®ãœãŒã¹ã³ãŒãã«ã¢ã¯ã»ã¹ã§ããŸãã
ã€ã³ã¹ããŒã«ïŒ
npm install belle
5.ãšããŒã°ãªãŒã³
React UIããªããã£ãã®äžã«æ§ç¯ãããEvergreenã¯ããããžã§ã¯ãã®æ§ç¯ã«äœ¿çšã§ããé«å質ã®ã³ã³ããŒãã³ããå«ãUIãã¬ãŒã ã¯ãŒã¯ã§ããéçºè ã¯ãã³ã³ããŒãã³ãã®ã€ã³ããŒããç°¡åãªãã®ããŒã«ãæ°ã«å ¥ã£ãŠããŸãã
Evergreenã¯MITã©ã€ã»ã³ã¹ã®äžã§ãªãªãŒã¹ãããŠããã GitHubãªããžããªã§ãã®ãœãŒã¹ã³ãŒãã«ã¢ã¯ã»ã¹ã§ããŸãã
ã€ã³ã¹ããŒã«ïŒ
npm install --save evergreen-ui
6.ããã
Bitã¯ãReactã¢ããªãå ¬éããã³å ±æããããã®ãªã³ã©ã€ã³ãã©ãããã©ãŒã ããã³ã³ãã³ãã©ã€ã³ããŒã«ã§ããããã¯ãã³ã³ããŒãã³ããæ§ç¯ããã³å ±æããå Žåã®æè¯ã®ãªãã·ã§ã³ã®1ã€ã§ãããã®ããŒã±ãããã¬ã€ã¹ã¯ã人ã ãReactã¢ããªãå ¬éããå¿ èŠãªã³ã³ããŒãã³ããæ€çŽ¢ã§ããå Žæã§ãããã®ãããæ°ããReactã¢ããªãã³ã³ããŒãã³ããå¿ èŠã«ãªããã³ã«ãã€ãŒã«ãäœãçŽãå¿ èŠã¯ãããŸããã
ã ãããããïŒ
- ã³ãŒãã®åå©çšãæäŸããŸãã
- èšèšãšéçºã®å¹çãé«ããŸãã
- UIãšUXã®äžè²«æ§ãç¶æããŸãã
- ãããžã§ã¯ãã®å®å®æ§ãé«ããŸãã
Bitã¯Apache2.0ã©ã€ã»ã³ã¹ã®äžã§ãªãªãŒã¹ãããŠããã GitHubãªããžããªã§ãã®ãœãŒã¹ã³ãŒãã«ã¢ã¯ã»ã¹ã§ããŸãã
ã€ã³ã¹ããŒã«ïŒ
$ npm install bit-bin --global
7.ã¹ããŒãªãŒããã¯
Storybookã¯ãUIã³ã³ããŒãã³ããè¿ éã«éçºããããã®ããŒã«ã§ããã³ã³ããŒãã³ãã®ã©ã€ãã©ãªã衚瀺ããåã³ã³ããŒãã³ãã®ã¹ããŒã¿ã¹ã远跡ã§ããŸããStoryBookã䜿çšãããšãã¢ããªã±ãŒã·ã§ã³ãšã¯å¥ã«ã³ã³ããŒãã³ããéçºã§ãããããUIã³ã³ããŒãã³ãã®åå©çšãšãã¹ãã容æã«ãªããŸãã
ããã«ãStorybook APIã¯å€ãã®æ©èœãæäŸããã«ã¹ã¿ãã€ãºã容æã«ããŸããCourseraãSquarespaceãLonelyPlanetãªã©ã®äŒæ¥ããã®ããŒã«ã䜿çšããŠããŸãã
Storybookã¯MITã©ã€ã»ã³ã¹ã®äžã§ãªãªãŒã¹ãããŠããã GitHubãªããžããªã§ãã®ãœãŒã¹ã³ãŒãã«ã¢ã¯ã»ã¹ã§ããŸãã
ãŸãã次ã®ã³ãã³ãã䜿çšããŠStorybookãã€ã³ã¹ããŒã«ããŸãã
$ cd my-react-app
$ npx -p @storybook/cli sb init
次ã«ãrunã³ãã³ããå®è¡ããŸãã
$ npm run storybook
8. Formik
Formikã¯ããããã°ããã¹ããããã³åæäžã«ãã©ãŒã ãäœæããã³æ€èšŒããã®ã«åœ¹ç«ã¡ãŸããåçãã©ãŒã ãäœæã§ãããããã³ã³ããŒãã³ãã®ç¶æ ãå°éå ·ãæåã§å€æŽãŸãã¯æŽæ°ããå¿ èŠã¯ãããŸãããããã«ãããéçºãããéãããã楜ãããªããŸãã
Formikã¯MITã©ã€ã»ã³ã¹ã®äžã§ãªãªãŒã¹ãããŠããã GitHubãªããžããªã§ãã®ãœãŒã¹ã³ãŒãã«ã¢ã¯ã»ã¹ã§ããŸãã
ã€ã³ã¹ããŒã«ïŒ
$ npm install formik --save
9.ã€ããŒ
Immerã¯ããããžã§ã¯ãæ§é ãããè€éã«ãªã£ããšãã«äžå€æ§ãç¶æã§ããããã«ããjsã©ã€ãã©ãªã§ããããæ£ç¢ºã«ã¯ãã©ã€ãã©ãªã䜿çšãããšãã³ãŒããäžå€ã«ä¿ã€ããšãç°¡åã«ãªããŸãã
Immerã®äž»ãªæ©èœã®ããã€ãã¯æ¬¡ã®ãšããã§ãã
- ã€ããŒã¯å³å¯ã«åæå®ãããŠããŸããããã¯ãç¶æ ãªããžã§ã¯ããåã§ããå Žåã«åœ¹ç«ã¡ãŸãã
- ã€ããŒã¯ãã€ã©ãŒãã¬ãŒããçž®å°ããŸãïŒã»ãšãã©ã®ç¶æ 管çããŒã«ã§ã¯ããã€ã©ãŒãã¬ãŒãã³ãŒããããããæžãå¿ èŠããããŸããImmerã䜿çšãããšãããå°ãªãã³ãŒããèšè¿°ã§ããŸãã
- Immerã䜿çšãããšãJSããŒã¿æ§é ã䜿çšã§ããŸããåºæ¬çãªJSããŒã¿æ§é ã䜿çšããŠãImmerã§äžå€ã®ç¶æ ãäœæã§ããŸãã
Immerã¯MITã©ã€ã»ã³ã¹ã®äžã§ãªãªãŒã¹ãããŠããã GitHubãªããžããªã§ãã®ãœãŒã¹ã³ãŒãã«ã¢ã¯ã»ã¹ã§ããŸãã
ã€ã³ã¹ããŒã«ïŒ
$ npm install immer
10.åå¿ããã
React Protoã¯ãéçºè ãšãã¶ã€ããŒåãã®ã¢ããªãããã¿ã€ãã³ã°ããŒã«ã§ãããããžã§ã¯ãæ§é ãèšç»ããã®ã«åœ¹ç«ã¡ãäºåã«æ±ºå®ãäžãããšãã§ããŸãããããã£ãŠãéçºäžã«å€æŽãå ããæéãç¡é§ã«ããããšã¯ãããŸããããã®ããŒã«ã¯ãã³ãŒãã£ã³ã°ããããã¶ã€ã³ã奜ã人ã«ç¹ã«åœ¹ç«ã¡ãŸããããšãã°ãã³ãŒããäœæãã代ããã«èŠçŽ ããã©ãã°ã¢ã³ãããããã§ããŸãããã®ããŒã«ã¯ãéžæãããã¹ãŠã®ã³ã³ããŒãã³ãã«ããŒã¯ãä»ããååãããããã£ãããã³éå±€ãäžããã®ã«åœ¹ç«ã¡ãŸãã
React Protoã¯MITã©ã€ã»ã³ã¹ã®äžã§ãªãªãŒã¹ãããŠããã GitHubãªããžããªã§ãã®ãœãŒã¹ã³ãŒãã«ã¢ã¯ã»ã¹ã§ããŸãã
ã€ã³ã¹ããŒã«ããã«ã¯ãæåã«ãªããžããªããã©ãŒã¯ããŸãã次ã«ã以äžã䜿çšããŠäŸåé¢ä¿ãã€ã³ã¹ããŒã«ããŸãã
$ npm install
次ã«ã以äžãå®è¡ããŸãã
$ npm start
$ npm run dev
ããªãã®ãã£ãªã¢ã®æ°ããã¹ããã
åºæ¬çã«ãJavaScriptãšReactã®è³æã¯èªåã§ããããèŠã€ããããšãã§ããŸãããã ãããã®èšäºïŒããã³ä»ã®å€ãã®èšäºïŒã§èª¬ââæããããŒã«ã®è©³çŽ°ã«ã€ããŠã¯ãAwesome ReactGitHubãªããžããªã確èªããŠãã ããã
ãããã®ããŒã«ãç 究ããŠå®è£ ããããšã«ãããçç£æ§ãåäžããéçšäž»ã«ãšã£ãŠå±¥æŽæžãããé åçã«ãªããŸãã
åºå
ReactJSã¢ããªãŸãã¯ãã®ä»ã®ç®çã®ããã®ãµãŒããŒã å¿ èŠã§ããïŒææ°ã®åŒ·åãªAMDããã»ããµãæèŒãããšããã¯ãµãŒããŒã¯åé¡ãªãåäœããŸããæ¥çµŠä»ãã®å¹ åºãæ§æã