Upgrade to Pro — share decks privately, control downloads, hide ads and more …

非SPAなRailsアプリでレールに乗りつつReactを使う話

 非SPAなRailsアプリでレールに乗りつつReactを使う話

React反省会@Wantedlyさん

Kenta Suzuki

May 10, 2017
Tweet

More Decks by Kenta Suzuki

Other Decks in Programming

Transcript

  1. DPQZSJHIU D $SPXE8PSLTBMMSJHIUTSFTFSWFE 3FBDU൓লձ!8BOUFEMZᴺඇ41"ͳ3BJMTΞϓϦͰϨʔϧʹ৐Γͭͭ3FBDUΛ࢖͏࿩ᴺ!TV[BOHP w 41"ʹ͢Δඞཁੑ͸ߴ͘ͳ͔ͬͨɻ w ৽نࣄۀΛ"1*ϑϩϯτΤϯυ׬શʹ෼͚ͯ։ൃ͢ΔϦιʔε ͕ͳ͔ͬͨɻ w

    ͱ͸͍͑6*͕ॏཁͳϖʔδͰ͸ෳࡶͳը໘੍ޚΛK2VFSZͰॻ͖ ͨ͘ͳ͍ɾɾɾ 3FBDUΛ࢖͍͍ͨϞνϕʔγϣϯ  w 41"ʹ஌ݟͷ͋Δϝϯόʔ΋গͳ͔ͬͨͷͰɺ෦෼తʹಋೖΛ࢝ Ίͨ 3FBDUͷίϯϙʔωϯτΛ 3BJMTͷ7JFXʹຒΊࠐΉ
  2. DPQZSJHIU D $SPXE8PSLTBMMSJHIUTSFTFSWFE 3FBDU൓লձ!8BOUFEMZᴺඇ41"ͳ3BJMTΞϓϦͰϨʔϧʹ৐Γͭͭ3FBDUΛ࢖͏࿩ᴺ!TV[BOHP ࢖༻͍ͯ͠Δٕज़ελοΫ w 3FBDU w 3FEVY w

    &4 w ZBSO w #BCFM w 8FCQBDL w SFBDU@PO@SBJMTSFBDUSBJMT 3FBDUͷߏ੒ͱͯ͠͸ ͘͘͝͝Ұൠతͳ΋ͷΛར༻͍ͯ͠·͢
  3. DPQZSJHIU D $SPXE8PSLTBMMSJHIUTSFTFSWFE 3FBDU൓লձ!8BOUFEMZᴺඇ41"ͳ3BJMTΞϓϦͰϨʔϧʹ৐Γͭͭ3FBDUΛ࢖͏࿩ᴺ!TV[BOHP w Ϟμϯ+4 &$."4DSJQUOQN ZBSO Λѻ͏ͨΊ3BJMTඪ४ͷ4QSPDLFUT Ͱ͸ͳ͘8FCQBDLͰϏϧυ͢Δ

    w 8FCQBDL͸ QVCMJD ʹϏϧυͨ͠+4$44*NBHFɺٴͼϚχϑΣετ ϑΝΠϧΛ࡞੒͠·͢ɻ w 8FCQBDLͱ3BJMTͱͷΠϯςάϨʔγϣϯ͸ಠࣗͷϔϧύʔΛॻ͍ͯରԠ͠ ͍ͯ·͢ɻৄࡉ͸ͪ͜ΒͷϒϩάΛ֬͝ೝ͍ͩ͘͞ɻ IUUQFOHJOFFSDSPXEXPSLTKQFOUSZ 4QSPDLFUT8FCQBDL΁ͷҠߦ
  4. DPQZSJHIU D $SPXE8PSLTBMMSJHIUTSFTFSWFE 3FBDU൓লձ!8BOUFEMZᴺඇ41"ͳ3BJMTΞϓϦͰϨʔϧʹ৐Γͭͭ3FBDUΛ࢖͏࿩ᴺ!TV[BOHP w SFBDUSBJMT͸4QSPDLFUT͕લఏͷ࡞Γʹͳ͍ͬͯΔ
 ˞࠷ۙ8FCQBDLFSͷαϙʔτ͕ೖΓ·ͨ͠  w SFBDUSBJMT͸ίϯϙʔωϯτΛάϩʔόϧʹ഑ஔ͢Δඞཁ͕͋Δ


    ˞8FCQBDLFSΛར༻͢Δ৔߹͸͜ͷݶΓͰ͸ͳ͍Α͏Ͱ͢  w SFBDU@PO@SBJMT͸SFBDU@VKTతͳ+4͕ɺOQNύοέʔδͱͯ͠ఏڙ͞Ε͍ͯͯ JNQPSUͯ͠࢖͑Δ SFBDU@PO@SBJMTWTSFBDUSBJMT 5-%3 8FCQBDLΛ࢖͏৔߹͸SFBDU@PO@SBJMTͷํ͕Αͦ͞͏
  5. DPQZSJHIU D $SPXE8PSLTBMMSJHIUTSFTFSWFE 3FBDU൓লձ!8BOUFEMZᴺඇ41"ͳ3BJMTΞϓϦͰϨʔϧʹ৐Γͭͭ3FBDUΛ࢖͏࿩ᴺ!TV[BOHP ͜͏͍͏ͷ΋ ϔομʔ 3BJMTͷ7JFX ϔομʔ 3BJMTͷ7JFX 3FBDUͷ

    ίϯϙʔωϯτ ΄΅ಉ͡ϚʔΫΞοϓ ΄΅ಉ͡ϚʔΫΞοϓ RailsͷԿ͔ෳࡶͳϔϧύʔ RailsͷԿ͔ifจ ඇReactͳJSͷΠϕϯτόΠϯυ
  6. DPQZSJHIU D $SPXE8PSLTBMMSJHIUTSFTFSWFE 3FBDU൓লձ!8BOUFEMZᴺඇ41"ͳ3BJMTΞϓϦͰϨʔϧʹ৐Γͭͭ3FBDUΛ࢖͏࿩ᴺ!TV[BOHP ϑϩϯτ͔Β+40/Λऔಘ͢Δ৔߹͕ ૿͑Δͱɺ͖ͪΜͱͨ͠"1*ઃܭ͕ඞ ཁʹͳͬͯ͘Δ w ϑϩϯτͷ+4͕খ͍͞͏ͪ͸AGPSNBUKTPOAͱ͔ͰϨϯμϦϯ άΛ෼͚͍ͯͯ΋·͋ͦΜͳʹࠔΒͳ͍͔΋͠Εͳ͍͚Ͳɾɾɾ

    w ϑϩϯτͷ+4͕େ͖͘ͳΔͱɺαʔόʔଆͷΤϥʔϋϯυϦϯά IUNM͸ฦ͞ͳ͍Ͱ͠ΐ͏ ͱ͔ɺඇϩάΠϯ࣌ʹ"1*ୟ͔Ε ͨΒԿฦ͢ͷͱ͔ɺ৭ʑͱߟ͑Δඞཁ͕ग़ͯ͘Δ w εϚϗΞϓϦ༻ͷ"1*ͷΑ͏ʹ͖ͪΜͱઃܭ͍ͯ͘͠ඞཁ͕Ͱͯ ͘Δ
  7. DPQZSJHIU D $SPXE8PSLTBMMSJHIUTSFTFSWFE 3FBDU൓লձ!8BOUFEMZᴺඇ41"ͳ3BJMTΞϓϦͰϨʔϧʹ৐Γͭͭ3FBDUΛ࢖͏࿩ᴺ!TV[BOHP 3BJMT͔Β3FBDUʹͲ͏σʔλΛ ౉͔͢ w 3BJMT͔Β3FBDUʹͲ͏σʔλΛ౉͢ͷ͔͸Α͘ઃܭ͓͔ͯ͠ͳ ͍ͱ3FBDUͷίϯϙʔωϯτ͕େ͖͘ͳ͖ͬͯͨͱ͖ʹɺϩδο Ϋ͕αʔόʔαΠυͰ෼ࢄ͢Δ͜ͱʹͳΔ

    ͜ͱ΋͋Δ  w ίϯϙʔωϯτ͕খ͍͞͏ͪ͸ͦΕ΄Ͳ໰୊ʹͳΒͳ͍͕ɺϑϩ ϯτΤϯυଆͰ+40/Λऔಘ͢Δ͜ͱ͕ଟ͘ͳΔͱɺεϚϗΞϓ ϦΛ࡞Δͱ͖ͷΑ͏ʹ"1*ઃܭΛͪΌΜͱ΍Δඞཁ͕ग़ͯ͘Δɻ w 3BJMT͔ΒͲ͏3FBDUʹσʔλΛ౉͍ͯ͘͠ͷ͔ɺSLBNVSB͞ Μͷ΍Γํ͸ΊͬͪΌࢀߟʹͳͬͨɻ 3VCZPO3BJMTPO3FBDUPO443PO41"
  8. DPQZSJHIU D $SPXE8PSLTBMMSJHIUTSFTFSWFE 3FBDU൓লձ!8BOUFEMZᴺඇ41"ͳ3BJMTΞϓϦͰϨʔϧʹ৐Γͭͭ3FBDUΛ࢖͏࿩ᴺ!TV[BOHP ·ͱΊʙ൓ল఺ʙ w 3BJMTͷ7JFXͷҰ෦ʹখ͞ͳ3FBDUͷίϯϙʔωϯτΛຒ ΊࠐΉͷ͸؆୯͚ͩͲɺͦΜͳʹεέʔϧ͠ͳͦ͞͏ ˞ݸਓ ͷײ૝Ͱ͢

    ɻΞϓϦέʔγϣϯʹ΋ΑΓ·͕͢ɺਐԽͱͱ΋ ʹ݁ہͦͷϖʔδ୯ମͰ͸41"Έ͍ͨͳ࡞ΓʹਐԽ͍ͯ͠ ͘ؾ͕͢Δɻ w 7JFXΛͲͪΒ͕ϨϯμϦϯά͢Δͷ͔ɺ1SPQTΛͲ͏౉͢ ͔ͳͲɺ3FBDUͱ3BJMTͷ੹຿ΛͲ͜Ͱ੾Γ෼͚Δ͔Α͘ߟ ͑ͳ͍ͱɺͲͬͪͷΤίγεςϜʹ΋৐Εͯͳ͍ײ͕ग़ͯ དྷΔ͠ɺγεςϜͷෳࡶੑ͕͕͋Δɻ
  9. DPQZSJHIU D $SPXE8PSLTBMMSJHIUTSFTFSWFE 3FBDU൓লձ!8BOUFEMZᴺඇ41"ͳ3BJMTΞϓϦͰϨʔϧʹ৐Γͭͭ3FBDUΛ࢖͏࿩ᴺ!TV[BOHP 3FBDUΛ࢖͏ϖʔδͰ͸ɺ 3BJMT͸جຊతʹ"1*ʹపͯ͠ 41"తͳ࡞Γʹ͢Δ w 3FBDUΛ࢖͏ϖʔδ PS͋Δ63-഑Լ

    Ͱ͸7JFX͸શͯ3FBDUͷίϯ ϙʔωϯτͰهड़͢ΔΑ͏ʹ͢Δ w 3FBDU΍ͦͷपลϥΠϒϥϦ͸41"Λલఏʹ͍ͯ͠Δ ͱײ͡Δ ͷͰɺ 3BJMT͸"1*  7JFX͸શͯ3FBDUʹ೚ͤΔͱ͍͏ελϯεΛऔͬͨ΄ ͏͕ɺ݁Ռͱͯ͠͸ͲͪΒͷΤίγεςϜͷԸܙΛड͚ΒΕͦ͏ɻ w શ෦41"ʹ͢ΔʹͤΑ͠ͳ͍ʹͤΑɺASFBDU@DPNQPOFOUAʹΑΔ 3BJMTͱ3FBDUͷεϜʔζͳΠϯςάϨʔγϣϯͱ͔ٻΊͣʹɺ໌֬ ʹ੹຿Λ੾Γ෼͚ΔΑ͏ʹ͍ͨ͠ʂ