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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
John Bartos
March 16, 2016
Programming
210
0
Share
Responsive D3 The React Way
Use higher-order components to abstract the nastiness of interacting with the real DOM
John Bartos
March 16, 2016
Other Decks in Programming
See All in Programming
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
2.6k
Technical Debt: Understanding it Rightly, Engaging it Rightly #LaravelLiveJP
shogogg
0
180
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
100
RailsTokyo 2026#4: AI様があれば、 Hotwireの弱点は消えるか?
naofumi
5
1k
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
400
Transactional Change Stream Processing With Debezium and Apache Flink
gunnarmorling
1
150
Stage 3 Decorators でできること / できないこと / TSKaigi 2026
susisu
1
1.4k
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
140
Migrations : C'est une question d'hygiène !
vinceamstoutz
0
2.7k
New "Type" system on PicoRuby
pocke
1
400
さぁV100、メモリをお食べ・・・
nilpe
0
120
柔軟なPDFレイアウトエディタを支える型システム設計 — Discriminated UnionとConditional Typeの実践
minako__ph
4
1.2k
Featured
See All Featured
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
190
WENDY [Excerpt]
tessaabrams
11
38k
Scaling GitHub
holman
464
140k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
Building AI with AI
inesmontani
PRO
1
1k
How to Talk to Developers About Accessibility
jct
2
210
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
760
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.3k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
570
Designing Powerful Visuals for Engaging Learning
tmiket
1
390
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
The Cult of Friendly URLs
andyhume
79
6.9k
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)