æšå¹Žãç§ã¯1æéåã®é·ãã¬ãã¹ã³ãè²»ãããŸãããããã§ã¯ãReactãå®éã«ç 究ãã倧å°ã®ã¢ããªã±ãŒã·ã§ã³ãäœæããåžžã«ãŒãããã©ã€ãã§è¡ããŸããã ç§ã¯ãããã®ãã¢ããã°ã©ãã³ã°ã®ã»ãã·ã§ã³ãåžžã«æŸéããŠãããããã¯ç§ã®ããŒãããŒãšãç§ãã¡ãšäžç·ã«ã³ãŒããæžããŠã©ã€ãã§è³ªåãã人ã ã«äž»ãªå©çããããããŸããã ããããæè¡ã®ç 究ã«ãããå®è·µã¯æãéèŠã§ãã
ãããããã®ãããªã¬ãã¹ã³ã1æéåç»é¢ã§èŠãã®ã¯èãé£ãã»ã©å°é£ã§ãããåžžã«åãããšãç¹°ãè¿ããèè ã®é·ããéå±ãªãçºèšããç¥èã®ã¬ãŒãºã³ãèŠã€ããŸããããšãŠãé£ããã§ãã ããã«ããããããããã¢ããã°ã©ãã³ã°ã®æ¯é±ã®ã»ãã·ã§ã³ã«äŸåããŠããéçºè ã®å€§éšåã¯ãèªåèªèº«ã§æ°ããReactãåŠã³ã倧èŠæš¡ãªãããžã§ã¯ãã®è€éãªã¿ã¹ã¯ãæ£åžžã«å®è¡ããŸããã ããããããããèŠãã®ã¯éå±ã§ãã ã©ããã
ã·ã§ãŒããã³ãããããŸããã ç§ã¯éå»ã®ã¬ãã¹ã³ãããã¹ãŠã®ã¬ãŒãºã³ãéããå®éã«ãããã質åãšãã€ã³ã¿ãã¥ãŒã®åå¿è ã®ããã®ç©ŽãéããŠã3-4åã®ã¯ãªããã«å€ããŸããã ã·ã§ãŒãã®ååïŒãµã³ãã«ã³ãŒãã5å以å ãäºåã«ãã€ã€ã«ãããã³ãŒããäºçŽ°ãªã³ã³ãã³ããªããå®è·µã«ããåé¡ã®ç¢ºèªã
ç§ã¯èª°ã§ããïŒ Wetzel Eugeneã w3bsit3-dns.comã®äœæè ã SFã®ãžã£ã³ã«ã®æ¬ã®èè ã倧èŠæš¡ãªããã³ããšã³ãäŒæ¥CSSSRã®ããŒã ã®ãã¯ã©ã€ã ã
CSSSR ShortsïŒ1ïŒCodePenã§ã®React Jsã®å±é
ES6èšèªä»æ§ã䜿çšããŠReactã®ã³ãŒããèšè¿°ã§ãããªã³ã©ã€ã³ã³ãŒããšãã£ã¿ãŒã®æå°èšå®ã«é¢ããã¹ããŒãªãŒ
çãã³ãŒãïŒ codepen.io/Imater/pen/XpLbrg
CSSSR ShortsïŒ2ïŒCodePenã§React Js + Reduxããããã€ãã
ES6èšèªä»æ§ã䜿çšããŠReact + Reduxã®ã³ãŒããèšè¿°ã§ãããªã³ã©ã€ã³ã³ãŒããšãã£ã¿ãŒã®æå°èšå®ã«é¢ããã¹ããŒãªãŒã ããã«ãreduxã䜿çšããæå°éã®ã³ãŒãã®äŸã
çãã³ãŒãïŒ codepen.io/Imater/pen/JEQdGv
CSSSR Shorts No. 3ïŒshouldComponentUpdate-ã³ã³ããŒãã³ãã®æŽæ°ç®¡ç
Reactãåå¿è åãã®é«éãã¹ã¯ã§ãããšããäºå®ã¯ãäœãããªããã°ããŠãŒã¶ãŒã®ã¢ã¯ã·ã§ã³ã«ãã£ãŠã¢ããªã±ãŒã·ã§ã³å šäœãåæç»ããããšããäºå®ã§ãã ãã®ãã¥ãŒããªã¢ã«ã§ã¯ãã¬ã³ããªã³ã°é¢æ°ã®äžå¿ èŠãªåŒã³åºããé²æ¢ãããReactããã©ãŒãã³ã¹ã®åºæ¬ã«ã€ããŠèª¬æããŸãã
çãã³ãŒãïŒ codepen.io/Imater/pen/pRXJPe
CSSSR ShortsïŒ4ïŒããã©ãŒãã³ã¹ãæãªãå°éå ·
renderé¢æ°ã®äžå¿ èŠãªåŒã³åºãã«ã€ãªããæãäžè¬çãªãšã©ãŒã¯ãpropsã³ã³ããŒãã³ããæž¡ãããšã§ãããã®ã³ã³ããŒãã³ããžã®ãªã³ã¯ã¯æ¯ååäœæãããŸãã éåžžã¯ç¡å®³ã«èŠããããã倧èŠæš¡ãªã¢ããªã±ãŒã·ã§ã³ã§ã¯ãããé²ãããã«ç®ãèšç·Žããå¿ èŠããããŸãã PureComponentã®ç®çãèæ ®ãããŸããããã¯ããã¹ãŠã®å°éå ·ãéå»ã®å€ãšæ¯èŒããäœãå€æŽããªããã°ã¬ã³ããŒã®åŒã³åºããåé¿ããŸãã
çãã³ãŒãïŒ codepen.io/Imater/pen/pRXJaw
CSSSR ShortsïŒ5ïŒã³ã³ããŒãã³ãã®ç¶æ ã®å€æŽã¯PureComponentã®ã¬ã³ããªã³ã°ã«åœ±é¿ããŸãã
å®éã«ã¯ãthis.setStateïŒïŒãåŒã³åºããšãã«pureComponentã³ã³ããŒãã³ãé¢æ°ãåŒã³åºããããã©ããã調ã¹ãŸãã
çãã³ãŒãïŒ codepen.io/Imater/pen/ZLdbwN
CSSSR ShortsïŒ6ïŒthis.setStateã®3ã€ãé£ç¶ããŠåŒã³åºããããšãã«renderãåŒã³åºãããåæ°
Reactãé«éåããããã«è€æ°ã®setStateãçµã¿åãããå¿ èŠããããŸãã
çãã³ãŒãïŒ codepen.io/Imater/pen/JEQYgX
CSSSR ShortsïŒ7ïŒã³ãŒãã«å¹²æžããããšãªãconsole.logã§ãããã°ãã
åŒã䜿çšããŠãconsole.logããundefinedããè¿ããšããäºå®ãå©çšããŠãconsole.logïŒvarïŒ|| var`å€æ°ã衚瀺ããŠãã³ãŒããžã®å¹²æžãæå°éã«æããããšãã§ããŸãã ç¢å°é¢æ°ãŸãã¯ãªããžã§ã¯ãã§éåžžã«äŸ¿å©ã§ãã
çãã³ãŒãïŒ codepen.io/Imater/pen/jyjWOd
CSSSR Shorts No. 8ïŒReduxã15è¡ã§èšè¿°ããReactãªãã§äœ¿çšããŸã
å éšã§reduxãã©ã®ããã«æ©èœããããç解ããã³ãŒãã®å éšãèŠãªãã£ã人ãå¿ ç¶çã«åãå·»ããã¹ãŠã®éæ³ãææããã«ã¯ããã®ã¬ãã¹ã³ãŸãã¯ã³ãŒããã芧ãã ããã
ã¬ãã¹ã³ã³ãŒãïŒ codepen.io/Imater/pen/pRMexM
CSSSR ShortsïŒ9ïŒReactã³ã³ããŒãã³ãã§é¢æ°ãäœæãããã®ã³ã³ããã¹ããæž¡ãããã®ãªãã·ã§ã³
ã¯ã©ã¹ïŒReactã³ã³ããŒãã³ãïŒã«é¢æ°ãèšè¿°ããããã®6ã€ã®ãªãã·ã§ã³ãæ€èšãããã®é¢æ°ãé¢æ°å ã§ç°ãªãã³ã³ããã¹ããæã£ãŠããçç±ãç解ããŠãã ããã ã³ãŒããèŠããšãã€ã³ã¿ãã¥ãŒã§ããèŠãããããŸããŸãªãªãã·ã§ã³ãæ°žé ã«æãåºããå®éã®ãããžã§ã¯ãã§æ··ä¹±ãåŒãèµ·ãããŸãã
çãã³ãŒãïŒ stackblitz.com/edit/react-m32gzi
CSSSR Shorts No. 10ïŒMemoizeeãã£ãã·ã³ã°ãããã³Reactã¢ããªã±ãŒã·ã§ã³ã®æé©åãå¿ èŠãªçç±
ãã£ãã·ã³ã°æ©èœã®å®è£ ãšãReactã³ã³ããŒãã³ãã®äžèŠãªãªã¢ã¯ã¿ãŒãæé€ããããã®ãã®äœ¿çšã
çãã³ãŒãïŒ stackblitz.com/edit/react-7opmc8?file=index.js
CSSSR Shorts No. 11ïŒå®è¡åã«é¢æ°ã«ããŒã¿ãæž¡ãããã®Memoizeeãã£ãã·ã¥
memoizeeã䜿çšããå¥ã®æ¹æ³ãæ€èšããŠãã ãããå®è¡åã«åŒæ°ãæž¡ãããã«é¢æ°ãè¿ãé¢æ°ããã£ãã·ã¥ããŸãã
çãã³ãŒãïŒ stackblitz.com/edit/memoizee-on-click?file=index.js
CSSSR Shorts No. 12ïŒå®æ°ããã³ã³ããŒãã³ãåã䜿çšããããŸããŸãªæ¡ä»¶äžã§ã®ã¬ã€ã¢ãŠãã容æã«ããŸã
å€æ°ã§äœ¿çšãããã³ã³ããŒãã³ãã®ååãæ ŒçŽããçããæ¹æ³ã ããŸããŸãªæ¡ä»¶äžã§ã®ã¬ã€ã¢ãŠãå€æŽã«åœ¹ç«ã¡ãŸãã
çãã³ãŒãïŒ stackblitz.com/edit/component-name?file=index.js
CSSSR ShortsïŒ13ïŒå®éã«ã³ãŒããå€æŽããã«å€æ°ãã³ã³ãœãŒã«ã«åºåãã
Chromeã®æ¡ä»¶ä»ããã¬ãŒã¯ãã€ã³ãã¯ãã³ã³ãœãŒã«ã«åºåã³ãŒããè¿œå ããããåæ¢æ¡ä»¶ããããã°ããã®ã«äŸ¿å©ã§ãã
çãã³ãŒãïŒ stackblitz.com/edit/component-name?file=index.js
CSSSR ShortsïŒ14ïŒåéžæ-ããã¹ããŒããªãã£ãã·ã³ã°æ©èœ
åéžæã¯ãReactã³ã³ããŒãã³ãã®äžå¿ èŠãªåã¬ã³ããªã³ã°ãæé€ããèªåãã£ãã·ã¥ã§è€éãªã»ã¬ã¯ã¿ãŒãäœæããã®ã«åœ¹ç«ã¡ãŸãã äž»ãªå©äŸ¿æ§ã¯ããã£ãã·ã¥ããŒãè¿ããã¹ãŠã®é¢æ°ãåãåŒæ°ã®ã»ãããåãåãããšã§ãã reduxã®å Žåãã¹ãã¬ãŒãžå šäœãå ¥åã«éä¿¡ããæ¹ãé©åã§ããã°ããŒãã«ã»ã¬ã¯ã¿ãŒã¯ãå šèœãã§ãããã¢ããªã±ãŒã·ã§ã³ã®ç¶æ å šäœããåºåãåéã§ããŸãã ãããã£ãŠãã¹ãã¬ãŒãžå šäœãåŒæ°ãšããŠäœ¿çšããå Žåãçžäºã«çµåããã»ã¬ã¯ã¿ãŒã§ã¢ããªã±ãŒã·ã§ã³å šäœãäœæã§ããŸãã
çãã³ãŒãïŒ stackblitz.com/edit/reselect?file=index.js
CSSSR ShortsïŒ15ïŒRedux Connectæ©èœã§ã®ãã£ãã·ã¥ã®åéžæ
Reduxã®æ¥ç¶æ©èœã§ãã£ãã·ã¥ãåéžæãããšãäžèŠãªã³ã³ããŒãã³ãã¬ã³ãã©ãŒããªããªããŸãã 1ã€ã®ã¬ãã¥ãŒãµãŒäžã®1ã€ã®ãªããžããªã§reduxã䜿çšããŸãã ããŒã¿ã¯å€æŽãããŠããªãããããããžã®ãªã³ã¯ã¯å€æŽãããŠããå Žåã®è¿œå ã®ã¬ã³ãã©ãŒã瀺ããŸãã 4ã€ã®RamdaJsé¢æ°ã䜿çšããŸãïŒpathãsortByãpropãcomposeã
åéžæãªãã®çãã³ãŒãïŒ stackblitz.com/edit/redux-simple-bad?file=index.js
åéžæã䌎ãã³ãŒãã®ã·ã§ãŒãã¬ã¯ãïŒ stackblitz.com/edit/redux-simple-with-reselect?file=index.js
CSSSR Shorts No. 16ïŒRedux圢åŒã®æå°äœ¿çšäŸ
Redux-formã¯æå°éã®äœ¿çšäŸã§ãã ä»ã®ã¹ãã¬ãŒãžããã®åæå€ã®åæåã æå°éã®redux圢åŒã®æ¥ç¶ã³ãŒãã®ä»çµã¿ã«é¢ããã¹ããŒãªãŒã è€æ°ã®æžéæ©ã®çµã¿åããã R.composeã䜿çšããŠããªããžããªãšreduxFormã«æ¥ç¶ãããã³ã³ããŒãã³ããäœæããéã®æ¬åŒ§ã®æ°ãæå°éã«æããŸãã
çãã³ãŒãïŒ stackblitz.com/edit/redux-form-v1?file=index.js
CSSSR ShortsïŒ17ïŒããŒãã©ã€ãºã«ãããã£ãŒã«ãreduxFormã®ãã¹ã¯
å ¥åäžã«8922884848ã2017幎12æ1æ¥ã«8-922-88-48-48ãŸãã¯12012017ã«å€æããå¿ èŠãããå Žåã¯ã©ãããã°ããã§ããïŒ åçïŒnormalizeã䜿çšãããšãçŸåšã®å ¥åãã£ãŒã«ãã ãã§ãªãããã¹ãŠã®ãã©ãŒã ãã£ãŒã«ãã®ãã¹ãŠã®å€ã®æ°ããéå»ã®å€ãååŸãããŸãã ãã®æ å ±ã䜿çšããŠãçŸåšã®ãã£ãŒã«ãã®æ°ããå€ãèšç®ããŸãã
ã·ã§ãŒãã³ãŒãïŒ stackblitz.com/edit/redux-form-v2-normalize?file=index.js
CSSSR ShortsïŒ18ïŒreduxFormã®ãã€ãã£ãå ¥åã³ã³ããŒãã³ã
ã¯ã©ã¹ãšããŠäœæããåçŽãªå ¥åã³ã³ããŒãã³ããèŠãŠã¿ãŸãããã ãã®ã³ã³ããŒãã³ããåãåãããããã£ã«ã€ããŠèª¬æããŸãã
çãã³ãŒãïŒ stackblitz.com/edit/redux-form-v3-component?file=index.js
CSSSR Shorts No. 19ïŒãã©ãŒã å ã®ãã¿ã³ã®ã¿ã€ããå¿ãããšã©ããªããŸãã
ãã¿ã³ã§type = "button"ãå¿ããå Žåããã©ãŒã ãéä¿¡ãããšããã®ãã¿ã³ã¯onClickãåŒã³åºããŸãã
çãã³ãŒãïŒ codesandbox.io/s/y2ql953m9j
CSSSR ShortsïŒ20ïŒreduxFormã®ãã¹ããããããŒã¿æ§é
FormSectionã䜿çšããŠãä»»æã®æ·±ãã®ãã¹ããããããŒã¿æ§é ãæå®ãã
çãã³ãŒãïŒ codesandbox.io/s/8x02q1jro8
CSSSR Shorts No. 21ïŒãã©ãŒã ãããã£ãŒã«ãå€ãå€æŽããæ¹æ³
ãã©ãŒã ã®å€æŽæ©èœã䜿çšããŠããã¹ãã䜿çšããŠãã£ãŒã«ãå€ãèšå®ãã
çãã³ãŒãïŒ codesandbox.io/s/8x02q1jro8
CSSSR Shorts No. 22ïŒåäžã®é¢æ°ã§è€æ°ã®ãã£ãŒã«ããå€æŽãã
å€æŽæ©èœã䜿çšããŠredux-formã§è€æ°ã®ãã£ãŒã«ããäžåºŠã«å€æŽãã
çãã³ãŒãïŒ codesandbox.io/s/7wxkvww01j
CSSSR ShortsïŒ23ïŒreduxFormã«initialValuesã®ã¹ãã¬ãŒãžããªãã¹ã³ããã
enableReinitializeããããã£reduxFormã¯ãã¹ãã¢ã§ããŒã¿ãå€æŽããããšãã«ãã©ãŒã ã«initialValuesã匷å¶çã«æŽæ°ãããŸã
çãã³ãŒãïŒ codesandbox.io/s/7wxkvww01j
ãæž èŽããããšãããããŸããã æåã®4ã€ã®ã¯ãªããã§ãã€ã¯ãscããª
React shortsããããŠAngular 2+ãæ¯é±ä»é±äžã«å ¬éãããŸãã youtubeãã£ã³ãã«ã賌èªããŸãã ããã§ã®å€ã®ã«ã³ãã¡ã¬ã³ã¹ã®ãããªãèŠãŠãã ããã ç§ãã¡ã®ããã«åãã«æ¥ãŠãã ããã