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
Responsive D3 The React Way
Search
John Bartos
March 16, 2016
Programming
0
210
Responsive D3 The React Way
Use higher-order components to abstract the nastiness of interacting with the real DOM
John Bartos
March 16, 2016
Tweet
Share
Other Decks in Programming
See All in Programming
組織で育むオブザーバビリティ
ryota_hnk
0
170
CSC307 Lecture 03
javiergs
PRO
1
490
SourceGeneratorのススメ
htkym
0
190
OSSとなったswift-buildで Xcodeのビルドを差し替えられるため 自分でXcodeを直せる時代になっている ダイアモンド問題編
yimajo
3
610
CSC307 Lecture 05
javiergs
PRO
0
500
AIで開発はどれくらい加速したのか?AIエージェントによるコード生成を、現場の評価と研究開発の評価の両面からdeep diveしてみる
daisuketakeda
1
970
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
0
150
CSC307 Lecture 08
javiergs
PRO
0
670
カスタマーサクセス業務を変革したヘルススコアの実現と学び
_hummer0724
0
650
ぼくの開発環境2026
yuzneri
0
110
Smart Handoff/Pickup ガイド - Claude Code セッション管理
yukiigarashi
0
130
Lambda のコードストレージ容量に気をつけましょう
tattwan718
0
110
Featured
See All Featured
エンジニアに許された特別な時間の終わり
watany
106
230k
Making the Leap to Tech Lead
cromwellryan
135
9.7k
Designing Experiences People Love
moore
144
24k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
60
42k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
61
52k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
110
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
83
A Tale of Four Properties
chriscoyier
162
24k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
310
Building AI with AI
inesmontani
PRO
1
680
Raft: Consensus for Rubyists
vanstee
141
7.3k
Everyday Curiosity
cassininazir
0
130
Transcript
Making D3 Responsive The React Way https://johnbartos.github.io/react-d3-demo/ johnbartos.io
I'm John Bartos, and this is my first talk ever
You want to make sweet D3 visualizations that just work™
on all screen sizes (you also care about doing it properly)
But there's a problem...
D3 needs to know its size before runtime You don't
know size until runtime
Fortunately, there's an easy solution
ReactDOM.findDOMNode() GetBoundingClientRect() window.addEventListener('resize', ..) this.setState()
But there are two (2) things wrong with this approach!
findDOMNode() breaks component abstraction
A stateless component is now stateful
You need a higher-order component! (?)
HOCs are functions which take a component and returns another
component that wraps it (thats it)
Our HOC gets size exactly as before and passes it
as props to its child When 'resize' event fires, new props are passed, prompting a rerender
The HOC encapsulates all the nastiness
The wrapped component just gets props
There's a small catch – children render before parents Need
to set initial state in HOC
(Please clap)