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
CSC307 Lecture 15
javiergs
PRO
0
240
20260228_JAWS_Beginner_Kansai
takuyay0ne
5
470
Claude Code の Skill で複雑な既存仕様をすっきり整理しよう
yuichirokato
1
350
DevinとClaude Code、SREの現場で使い倒してみた件
karia
1
990
Go Conference mini in Sendai 2026 : Goに新機能を提案し実装されるまでのフロー徹底解説
yamatoya
0
550
Vuetify 3 → 4 何が変わった?差分と移行ポイント10分まとめ
koukimiura
0
110
Railsの気持ちを考えながらコントローラとビューを整頓する/tidying-rails-controllers-and-views-as-rails-think
moro
5
390
Claude Code、ちょっとした工夫で開発体験が変わる
tigertora7571
0
200
2026年は Rust 置き換えが流行る! / 20260220-niigata-5min-tech
girigiribauer
0
230
受け入れテスト駆動開発(ATDD)×AI駆動開発 AI時代のATDDの取り組み方を考える
kztakasaki
2
550
nilとは何か 〜interfaceの構造とnil!=nilから理解する〜
kuro_kurorrr
3
1.9k
Swift ConcurrencyでよりSwiftyに
yuukiw00w
0
250
Featured
See All Featured
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.9k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
Docker and Python
trallard
47
3.8k
Writing Fast Ruby
sferik
630
63k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
62
51k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.7k
Building the Perfect Custom Keyboard
takai
2
710
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
530
AI: The stuff that nobody shows you
jnunemaker
PRO
3
360
Designing Powerful Visuals for Engaging Learning
tmiket
0
270
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
470
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
140
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)