Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Rails loves React
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Yuichiro MASUI
December 31, 2017
Education
550
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rails loves React
Yuichiro MASUI
December 31, 2017
More Decks by Yuichiro MASUI
See All by Yuichiro MASUI
Coding Agent用チケットシステム - ticket.sh
masuidrive
0
54
Vue/Nuxt tutorial for Sendai
masuidrive
0
220
ハッカソンで 作ったアプリを売却した話
masuidrive
0
710
DJ hands on for IT Engineers
masuidrive
1
220
自分の棚卸をして レジュメを書こう
masuidrive
5
2k
0から1ヶ月で DJになるまで
masuidrive
4
1.6k
Google Apps Scriptでbotを作る話
masuidrive
1
1.8k
トレタの存在理由
masuidrive
0
250
18年でRubyから学んだこと - 関西Ruby会議 2017
masuidrive
3
2.3k
Other Decks in Education
See All in Education
2026年度春学期 統計学 第6回 データの関係を知る(1)ー 相関関係 (2026. 5. 14)
akiraasano
PRO
0
140
焦燥を平穏に変えるエンジニアのための哲学
ichimichi
7
4.9k
The Art & Science of Elearning
tmiket
1
230
Public Space Is Not For Sale
drikkes
0
120
2026年度春学期 統計学 第9回 確からしさを記述する ー 確率 (2026. 5. 28)
akiraasano
PRO
0
120
0506
cbtlibrary
0
210
AI時代に、 なぜ英語を勉強するのか
empelt
0
120
BITCOIN : Les fondamentaux !
rlifchitz
0
190
Info Session MSc Computer Science & MSc Applied Informatics
signer
PRO
0
300
면접관 눈에 띄는 데이터 분석 포트폴리오 만드는 법 | 2026년 5월 세미나
datarian
0
860
[2026前期火5] 論理学(京都大学文学部 前期 第12回)「証明を走らせる:カリー・ハワード対応」
yatabe
0
140
Data Management and Analytics Specialisation
signer
PRO
0
1.9k
Featured
See All Featured
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
450
Leo the Paperboy
mayatellez
7
1.9k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
The Limits of Empathy - UXLibs8
cassininazir
1
380
Rails Girls Zürich Keynote
gr2m
96
14k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
590
Designing for Performance
lara
611
70k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
800
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
380
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
1.9k
Transcript
Rails ♥ React Yuichiro MASUI / Toreta, Inc.
@masuidrive ૿Ҫ ༤Ұ
What’s React • FacebookJavascriptͷViewΤϯδϯ • TwitterAbema.tv ͳͲେنʹΘΕͯΔ • ߏతʹαʔόαΠυ͖ •
ϥΠηϯεͰᎍΊ͚ͨͲMITͰམ͍ͪͭͨ
ΫϥΠΞϯτϩδοΫ αʔόαΠυੜ ϒϥβ ϩδοΫ (ίϯτϩʔϥ) ϦΫΤετ αʔό ΫϥΠΞϯτ Πϕϯτ (onSubmit)
React αʔόϩδοΫ HTMLੜ෦ (render) HTMLੜ෦ (ςϯϓϨʔτ) ը໘Λදࣔ͢ΔͨΊͷঢ়ଶ (setState) ը໘Λදࣔ͢ΔͨΊͷঢ়ଶ (ςϯϓϨʔτม)
ͳͥReactΛ͏ͷ͔ • jQuery͏Ί͍ͨ • ϖʔδͰͷঢ়ଶͷมԽ͕ଟ͍ • WebSocketWebRTCͷΑ͏ͳ௨৴Λ͏ • Semantic-UIMaterial-UIͷΑ͏ͳϦονͳUIΛ͍͍ͨ
Rails + Rails • Webpacker + React (Rails 5.1͔Β •
react-rails (React७ਖ਼ Rails࿈ܞ • react_on_rails
Webpacker • Rails 5.1͔Βಋೖ͞Εͨ Webpack ͷϥούʔ • JavascriptCSSͷϏϧυπʔϧ • ΊͪΌͪ͘Ό໘
• ෦ͰBabelnode-sassΛݺͼग़͍ͯ͠Δ
Browserify • ϞμϯͳJavascriptΛϒϥβͰಈ͘Α͏ʹม • ίϯύΠϥͳͲ֎෦Λݺͼग़͢ • ҰͭͷϑΝΠϧ͚ͩϏϧυ͢ΔͳΒWebpackΑΓָ
None
Parcel bundler • ࠓேQiitaͰݟͯࢼͯ͠Έͨ • ιʔεΛݟͯґଘؔΛղੳͯ͠Ϗϧυ͢Δπʔϧ • ͜͏ͬͯ࣍ʑ৽͍͠πʔϧ͕ग़ͯ͘Δ
ڥΛ”ࠞͥΔͳةݥ” • ։ൃɾϦϦʔελΠϛϯάͷҧ͍ • ݴޠɾڥͷҧ͍ • ϥούʔେΊΜͲ͍͘͞
Nodeͷڥผʹ࡞Ζ͏ • DockerΛͬͯɺRailsͷڥͱReactͷڥΛ͚Δ • Ϗϧυڥผʹཧ • ࿈ಈͯ͠Ϗϧυ͢ΔΈͲ͏͢Δʁ
Dockerfile FROM ruby:2.4 ENV LANG C.UTF-8 RUN apt-get update &&
\ apt-get install -y nodejs mysql-client --no-install-recommends && \ rm -rf /var/lib/apt/lists/* && \ mkdir -p /usr/src/app WORKDIR /usr/src/app COPY Gemfile /usr/src/app/ COPY Gemfile.lock /usr/src/app/ RUN bundle install COPY . /usr/src/app EXPOSE 3000 CMD ["./bin/rails", "server", "-b", "0.0.0.0"]
react/Dockerfile FROM node:8 WORKDIR /usr/src/app ADD package.json /usr/src/app/package.json RUN yarn
install COPY . /usr/src/app
docker-compose.yml rails: build: . command: [ "bash", "-c", "rm -f
tmp/pids/server.pid; ./bin/rails server -b 0.0.0.0" ] environment: DISABLE_SPRING: "1" ports: - "3000:3000" volumes: - ".:/usr/src/app" links: - “mysql" react: build: react volumes: - "./react/src:/usr/src/app/src" - "./app/assets/javascripts:/usr/src/app/dist" - "node_modules" command: [ "yarn", "run", "watch" ] mysql: image: mysql:5.6 environment: MYSQL_ROOT_PASSWORD: "passwd"
σΟϨΫτϦߏ • root - ී௨ͷRails project • react - React෦ͷιʔεͱڥ
• app/javascripts - Ϗϧυ͞ΕͨReactίʔυ
ReactͷϏϧυ • browserifyΛ͏ browserify src/index.jsx -o dist/index -t [ babelify
-- presets [ es2015 react ] ] • Parcel bundlerΛ͏ parcel src/index.jsx • watchͰࢹ watch -p "src/**/*.js*" -c "yarn run build”
Pros / Cons • Pros • ಛผͳ࿈ܞϞδϡʔϧͳͲΛ༻͍ͳ͍ • Webpack͕ඞཁͳ͍ •
Cons • Dockerڥ͕ඞཁ • Ϗϧυ࣌ʹRailsͱ࿈ಈ͠ͳ͍
τϨλͷReact • ૿Ҫ͕ॻ͍͍ͯΔ͚ࣾπʔϧ͚ͩ • WebRTCWebSocketͬͨπʔϧ • Single Page ApplicationͰͳ͍
View͔Βͷݺͼํ • ը໘ຖʹಡΈࠐΉJavascriptΛͲ͏ܾఆ͢Δ͔ • ύϥϝʔλΛͲ͏ͬͯReactʹ͔͢
None
None
Form͚ͩReact
Α͋͘ΔϢʔβొ • ໊લɺϝΞυɺύεϫʔυ • validateͰ͖ͨΒSubmit͕ԡͤΔΑ͏ʹ • ௨৴ී௨ͷForm submit
None
None
None
None
XHR/fetch͠ͳͯ͘ React͏ͱศར
ͬͱෳࡶͳΒ
Redux • ReactͱڞʹΘΕΔϑϨʔϜϫʔΫ • ঢ়ଶΛมߋ͢ΔʹActionΛൃߦͯ͠ɺReducerͰStoreΛ มߋ͢Δ͔͠ͳ͍ • શͯͷঢ়ଶStoreʹอଘ͞ΕΔ
Hot load • Reactͷେ͖ͳಛ • ϒϥβΛϦϩʔυͤͣʹঢ়ଶΛͨ͠··DOMͷมߋ ͤ͞Δ • Reactͷঢ়ଶɺstateͱpropsʹೖ͍ͬͯΔͷͰɺ͜ΕΛ อ࣋ͨ͠··ΦϒδΣΫτπϦʔΛ࠶ߏங͢Δ
• ιʔείʔυͷมߋ௨WebSocketͰߦ͏
࠷ۙݟ͚ͭͨ ศརͳϥΠϒϥϦ
None