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
JS Summit: Modular React & Redux
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Jeremy Fairbank
February 25, 2016
Programming
500
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
JS Summit: Modular React & Redux
Jeremy Fairbank
February 25, 2016
More Decks by Jeremy Fairbank
See All by Jeremy Fairbank
Connect.Tech 2020: Advanced Cypress Testing
jfairbank
1
260
CodeMash 2020: Solving the Boolean Identity Crisis
jfairbank
1
220
CodeMash 2020: Practical Functional Programming
jfairbank
1
370
Connect.Tech 2019: Practical Functional Programming
jfairbank
0
440
Connect.Tech 2019: Solving the Boolean Identity Crisis
jfairbank
0
250
Lambda Squared 2019: Solving the Boolean Identity Crisis
jfairbank
0
190
All Things Open 2018: Practical Functional Programming
jfairbank
2
290
Connect.Tech 2018: Effective React Testing
jfairbank
1
220
Fluent Conf 2018: Building web apps with Elm Tutorial
jfairbank
2
930
Other Decks in Programming
See All in Programming
自分的「カンファレンスの楽しみ方」
syumai
0
160
Oxlintはいいぞ(続)
yug1224
1
500
MySQLとPostgreSQLって何が違うの?
akagami
0
150
片田舎のおっさん、 Swift Buildのダイアモンド問題解決の不具合修正PRを出すが、解決方法がキャッシュをしないようにすることであり、ビルド時間が伸びると言われてマージされないので高速化もする/swiftbuild
yimajo
0
330
私のClaude Code活用法 (個人開発編) - PHPerKaigi mini #4(2026/08/24)
panda_program
1
200
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.4k
How I Won Prize Money at a Hackathon Using Codex and Symphony Alpha
yasei_no_otoko
0
130
AIに既存システムを理解させる技術 ~レガシーを見捨てないハーネスエンジニアリング入門~
ochtum
0
180
初心者DevRelとして参加者だった私が、DevRel Talks!#2に登壇するまでにしてきたこと
sokohirai
0
250
新人はどこまで自力でやり、どこからAIに頼るべきか/エンジニア育成に向き合う_先輩たちの悩みと知見共有会
toppan_digital_dev
1
370
「つくるAI」だけではバグは見つからない ~テストに必要な「見つけるAI」を分離させる戦略~
mfunaki
0
220
Claude Code全社展開のためにやったことn選~プラグイン302個・コミッター271人を支えるために~
kenchan
5
1.8k
Featured
See All Featured
Everyday Curiosity
cassininazir
0
300
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
260
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
400
Practical Orchestrator
shlominoach
191
12k
From π to Pie charts
rasagy
0
340
What does AI have to do with Human Rights?
axbom
PRO
1
2.3k
Navigating Weather and Climate Data
rabernat
0
500
How STYLIGHT went responsive
nonsquared
100
6.3k
Code Reviewing Like a Champion
maltzj
528
40k
Exploring anti-patterns in Rails
aemeredith
3
490
Code Review Best Practice
trishagee
74
20k
Transcript
Jeremy Fairbank blog.jeremyfairbank.com @elpapapollo | github.com/jfairbank MODULAR React& redux
We help brands excel. pushagency.io Your website, SimplyBuilt. simplybuilt.com
https://commons.wikimedia.org/wiki/File:2001_Monolith.jpg
https://commons.wikimedia.org/wiki/File:Close_up_of_Hand_Cut_Jigsaw_Puzzle.JPG
Modularity • Independent • Single Responsibility • Small • Testable
• Apply to React components • Apply to Redux state and reducers
None
None
<Dashboard> <Panel label="Account"> <PanelItem>Name: {user.name}</PanelItem> <PanelItem>Username: {user.username}</PanelItem> <PanelItem>Email: {user.email}</PanelItem> </Panel>
</Dashboard>
class NameTag extends React.Component { componentWillMount() { this.setState({ name: this.props.name
}); } updateName(name) { this.setState({ name }); } render() { return ( <div> <p>Hello, my name is {this.state.name}</p> <p> <input type="text" value={this.state.name} onChange={e => this.updateName(e.target.value)} /> </p> </div> ); } } <NameTag name="Jeremy Fairbank"/>
<NameTag name="Jeremy Fairbank" onChange={myUpdateFunction}/> const NameTag = ({ name, onChange
}) => ( <div> <p> Hello, my name is {name} </p> <p> <input type="text" value={name} onChange={e => onChange(e.target.value)} /> </p> </div> );
PROBLEMS STATE AND RESPONSIBILITY
const NameTag = ({ name, onChange }) => ( <div>
<p> Hello, my name is {name} </p> <p> <input type="text" value={name} onChange={e => onChange(e.target.value)} /> </p> </div> ); External state
const NameTag = ({ name, onChange }) => ( <div>
<p> Hello, my name is {name} </p> <p> <input type="text" value={name} onChange={e => onChange(e.target.value)} /> </p> </div> ); Who manages the state?
class NameTag extends React.Component { componentWillMount() { this.setState({ name: this.props.name
}); } updateName(name) { this.setState({ name }); } render() { return ( <div> <p>Hello, my name is {this.state.name}</p> <p> <input type="text" value={this.state.name} onChange={e => this.updateName(e.target.value)} /> </p> </div> ); } }
class NameTag extends React.Component { componentWillMount() { this.setState({ name: this.props.name
}); } updateName(name) { this.setState({ name }); } render() { return ( <div> <p>Hello, my name is {this.state.name}</p> <p> <input type="text" value={this.state.name} onChange={e => this.updateName(e.target.value)} /> </p> </div> ); } }
class NameTag extends React.Component { componentWillMount() { this.setState({ name: this.props.name
}); } updateName(name) { this.setState({ name }); } render() { return ( <div> <p>Hello, my name is {this.state.name}</p> <p> <input type="text" value={this.state.name} onChange={e => this.updateName(e.target.value)} /> </p> </div> ); } } Many components => State strewn across app
class NameTag extends React.Component { componentWillMount() { this.setState({ name: this.props.name
}); } updateName(name) { this.setState({ name }); } render() { return ( <div> <p>Hello, my name is {this.state.name}</p> <p> <input type="text" value={this.state.name} onChange={e => this.updateName(e.target.value)} /> </p> </div> ); } } Intermingling view and behavior => Violating SRP
PROBLEMS PROPS FATIGUE
const App = ({ name, onChangeName }) => ( <AppDashboard
name={name} onChangeName={onChangeName}/> ); const AppDashboard = ({ name, onChangeName }) => ( <Dashboard> <Panel> <User name={name} onChangeName={onChangeName}/> </Panel> </Dashboard> ); const User = ({ name, onChangeName }) => ( <NameTag name={name} onChange={onChangeName}/> ); { name: 'Jeremy', onChangeName: (name) => { updateSomeGlobalState({ name }); } }
Wishlist • Manage state in one place outside of components
in a modular fashion. • Define behavior separate from view. • Inject props without deep passing. (Like partial application.)
+ Redux =
{ user: { name: 'Jeremy', email: '
[email protected]
', username: 'elpapapollo' }
} Store App
Provider & connect { user: { name: 'Jeremy', email: '
[email protected]
',
username: 'elpapapollo' } } Store App
{ name: 'Jet', type: 'UPDATE_NAME' } Action Provider & connect
{ user: { name: 'Jeremy', email: '
[email protected]
', username: 'elpapapollo' } } Store App Dispatch
{ name: 'Jet', type: 'UPDATE_NAME' } Action Provider & connect
{ user: { name: 'Jet', email: '
[email protected]
', username: 'elpapapollo' } } New Store State App Dispatch { user: { name: 'Jeremy', email: '
[email protected]
', username: 'elpapapollo' } } Store Reducer
<Demo> <ContactManager/> </Demo> Demo
Recap • Modularity • Modular React components • Modular Redux
reducers and state
Resources • facebook.github.io/react • redux.js.org • egghead.io/series/getting-started-with-redux
Jeremy Fairbank blog.jeremyfairbank.com @elpapapollo | github.com/jfairbank THANKS! Code: github.com/jfairbank/modular-react-and-redux-talk