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
Redux in Production
Search
Sam Yamashita
July 11, 2016
Technology
320
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Redux in Production
Sam Yamashita
July 11, 2016
More Decks by Sam Yamashita
See All by Sam Yamashita
AI が自動テストの分野でどのように使われるのか
unbabel
0
160
Thailand
unbabel
1
90
DX に優れた多言語化ドキュメント作成方法
unbabel
0
540
3 Tips for meeting
unbabel
0
290
What is GitHub Marketplace and good for?
unbabel
0
120
OSS 翻訳と GitLocalize
unbabel
0
550
Introduction to RAIL
unbabel
0
120
CSS Architecture
unbabel
1
79
Git・Githubに関する隠された便利な機能
unbabel
1
430
Other Decks in Technology
See All in Technology
強化学習「理論」入門
enakai00
3
3.6k
VLMで2.3万枚のPyCon JP写真を検索!
terapyon
1
220
猫付きpingコマンドを自作
uyuki234
0
290
2027年のMetricKit
kantacky
0
150
なぜ Temporal の大小比較には compare しかないのか / Why Does Temporal Only Have compare() for Comparisons
kazukihayase
1
200
AI-DLC実践録_フルサイクル開発への挑戦
miyuc
0
360
巨大気象データと戦う ― サロゲートモデル学習を高速化する圧縮技術
gpuunite_official
0
230
AIコーディングの次。コードレビューと理解負荷を解消して組織の開発生産性を高める
moongift
PRO
2
2.7k
AIのためのEthernet技術動向 (SerDes)
markunet
1
290
【CEDEC2026】Creative Approaches to Localizing the Dialects and Unique Speech of Umamusume: Pretty Derby Characters in English
cygames
PRO
4
26k
三人寄ればチューリング完全
puhitaku
6
2.7k
私がブラウザを自作したくなった理由
supurazako
1
280
Featured
See All Featured
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
470
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
480
What's in a price? How to price your products and services
michaelherold
247
13k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
500
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
710
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
420
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.5k
Writing Fast Ruby
sferik
630
63k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
570
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
66
57k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
Transcript
JS Night Redux in Production #dcubeio
github.com/sotayamashita twitter.com/sota0805 blog.sotayamashita.com 山下颯太 ソフトウェアエンジニア 株式会社サイバーエージェント 株式会社シロク
今日話すこと • Redux ͱʁ • Flux ͱʁ はじめに Growth Push
• Growth Pushͱʁ • എܠ • վमલͷߏ • վमޙͷߏ • Switch ͩΒ͚ͷ Reducer • ࠶ར༻Մೳͳ Component
Flux とは?
Action Dispatcher Store View Flux ͱʁ ਤ A cartoon intro
to Flux by Lin Clark
Reduxとは?
–Dan Abramov “I didn't actually intend Redux to become a
popular Flux library—I wrote it as I was working on my ReactEurope talk on hot reloading with time travel.” Reduxͱʁ Why use Redux over Facebook Flux?
Reduxͱʁ Store 内の state とそのロジックを分離 todos: [“eat”, “sleep”] todos: [“”,
“”] addTodo: (todo) => {} addTodo: (todo) => {} todos: [“eat”, “sleep”] addTodo: (todo) => {} todos: [“eat”, “sleep”] addTodo: (todo) => {} ߋ৽ 更新 更新 Before After ਤ A cartoon intro to Redux by Lin Clark
Reduxͱʁ State を action から直接上書きしない Before Action 1 Action2 Action
3 state ਤ A cartoon intro to Redux by Lin Clark
Reduxͱʁ State を action から直接上書きしない After Action 1 Action2 Action
3 state 1 state 2 state 3 ਤ A cartoon intro to Redux by Lin Clark
Reduxͱʁ 階層になっている state からなる 1つの大きな state Before dispatcher store store
store log ਤ A cartoon intro to Redux by Lin Clark
Reduxͱʁ ਤ A cartoon intro to Redux by Lin Clark
階層になっている state からなる 1つの大きな state After dispatcher reducer reducer reducer log reducer reducer reducer reducer reducer
Growth Push とは?
Growth Push ͱʁ http://growthpush.com/
վमલͷߏ • クライアントサイド MVC ライブラリ • テンプレートエンジン • Alt JavaScript
• フレームワーク
վमલͷߏ • クライアントサイド MVC ライブラリ • テンプレートエンジン • Alt JavaScript
• フレームワーク この部分を変更
վमޙͷߏ • フレームワーク • フロント SPA
Switch だらけの Reducer
tree . └── reducers ├── index.js ├── application.js ├── notification.js
├── client.js ├── event.js └── tag.js Switch ͩΒ͚ͷ Reducer
http://redux.js.org/docs/basics/Reducers.html Switch ͩΒ͚ͷ Reducer 1 import * as ActionTypes from
' ../actions/todoApp'; 2 3 function todoApp(state = initialState, action) { 4 switch (action.type) { 5 case ActionTypes.SET_VISIBILITY_FILTER: 6 return { 7 ...state, 8 visibilityFilter: action.filter 9 }; 10 default: 11 return state 12 } 13 }
https://github.com/acdlite/redux-actions Switch ͩΒ͚ͷ Reducer 1 const todoApp = handleActions({ 2
SET_VISIBILITY_FILTER: (state, action) => ({ 3 visibilityFilter: action.filter 4 }), 5 }), initialState );
Before After Switch ͩΒ͚ͷ Reducer 1 import * as ActionTypes
from ' ../actions/todoApp'; 2 3 function todoApp(state = initialState, action) { 4 switch (action.type) { 5 case ActionTypes.SET_VISIBILITY_FILTER: 6 return { 7 ...state, 8 visibilityFilter: action.filter 9 }; 10 default: 11 return state 12 } 13 } 1 const todoApp = handleActions({ 2 SET_VISIBILITY_FILTER: (state, action) => ({ 3 visibilityFilter: action.filter 4 }), 5 }), initialState );
再利用可能なコンポーネント
࠶ར༻Մೳͳίϯϙʔωϯτ • Container Components • Presentational Components
࠶ར༻Մೳͳίϯϙʔωϯτ Container Presentational Container と Presentational の関係性 State Presentational Presentational
Presentational
࠶ར༻Մೳͳίϯϙʔωϯτ Container Presentational Container と Presentational の関係性 Store Presentational Presentational
Presentational
࠶ར༻Մೳͳίϯϙʔωϯτ Container Presentational Container と Presentational の関係性 Store Presentational Presentational
Presentational ࠶ར༻͢Δͱ͜
࠶ར༻Մೳͳίϯϙʔωϯτ Container Presentational Container と Presentational の関係性 State Presentational Presentational
Presentational
࠶ར༻Մೳͳίϯϙʔωϯτ Container Components Presentational and Container Components • Redux であれば
connect() を使用してStore をもらうところ • スタイルをもたない傾向にある • 余計な DOM を含まない傾向にある • 例えば、 ユーザーページ、ログインページ
࠶ར༻Մೳͳίϯϙʔωϯτ Container Presentational Container と Presentational の関係性 Store Presentational Presentational
Presentational
࠶ར༻Մೳͳίϯϙʔωϯτ Presentational Components Presentational and Container Components • functional component
で実装できる傾向がある • スタイルをもちます • 実際の DOM を含みます • 例えば、 リスト、モーダル
࠶ར༻Մೳͳίϯϙʔωϯτ Presentational and Container Components 1 const TodoList = ({
todos }) => ( 2 <ul> 3 {todos.map(todo => 4 <Todo 5 key={todo.id} 6 { ...todo} 7 /> 8 )} 9 </ul> 10 ); 1 class todoPage extends React.Component { 2 render() { 3 return ( 4 <div> 5 <TodoList todos={this.props.todos} /> 6 </div> 7 ) 8 } 9 }
࠶ར༻Մೳͳίϯϙʔωϯτ Container Presentational Store Presentational Presentational Presentational
バケツリレー???
࠶ར༻Մೳͳίϯϙʔωϯτ Container Store Container Container Container Container
࠶ར༻Մೳͳίϯϙʔωϯτ 再利用可能とは?
࠶ར༻Մೳͳίϯϙʔωϯτ https://github.com/sotayamashita/curator
最後に
࠷ޙʹ • ドキュメントが充実してる • 日本語だったら @kuy さんの Qiita にある記事とか •
サンプルプロジェクトがたくさん • コミュニティが充実してる • サンプルプロジェクト作ってみた(全然間に合わなかった) • https://github.com/sotayamashita/curator
ご清聴ありがとうございました