Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
JS Summit: Modular React & Redux
Search
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
230
CodeMash 2020: Practical Functional Programming
jfairbank
1
370
Connect.Tech 2019: Practical Functional Programming
jfairbank
0
450
Connect.Tech 2019: Solving the Boolean Identity Crisis
jfairbank
0
270
Lambda Squared 2019: Solving the Boolean Identity Crisis
jfairbank
0
200
All Things Open 2018: Practical Functional Programming
jfairbank
2
290
Connect.Tech 2018: Effective React Testing
jfairbank
1
230
Fluent Conf 2018: Building web apps with Elm Tutorial
jfairbank
2
940
Other Decks in Programming
See All in Programming
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
520
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
6
13k
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
3.8k
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
2.9k
スマート反転とウェブアクセシビリティ
camiha
0
210
手動確認はもう限界 〜XCUITestでCustom URL Schemeの遷移を起動種別ごとに自動テストする〜 / Testing Custom URL Schemes with XCUITest
otouto
0
340
Turning Architecture into Unit Tests in the AI Era (NSSpain XIV)
steliosf
PRO
1
100
SONY CISC-NEWS NWS-1750 + NWB-225 フレームバッファの NetBSD/news68k ドライバ実装 / OSC2026Hiroshima
tsutsui
0
150
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
270
スマートフォンでモールス信号を送受信する 〜スマートフォンのLEDとカメラで作る光通信の設計と実装〜
atsuki_seo
0
190
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
2.5k
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
180
Featured
See All Featured
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
520
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
2k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
3
4.3k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
740
HDC tutorial
michielstock
2
910
GitHub's CSS Performance
jonrohan
1033
470k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
RailsConf 2023
tenderlove
30
1.6k
Everyday Curiosity
cassininazir
0
330
Un-Boring Meetings
codingconduct
0
430
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
The Curious Case for Waylosing
cassininazir
1
540
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