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
220
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
180
FDEが実現するAI駆動経営の現在地
gonta
2
280
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
210
20260722_microCMSで考える、AI時代のコンテンツ運用設計
yosh1
0
400
Go 1.27 における memory allocation の高速化
andpad
0
180
型も通る、synthも通る、それでも危ない 〜AIのCDKの権限とコストを機械で検証する〜 / It Passes Type Checks, It Passes Synth Checks, but It’s Still Risky — Automatically Verifying Permissions and Costs in AI’s CDK —
seike460
PRO
1
550
数百円から始めるRuby電子工作
tarosay
0
150
Claude Code全社展開のためにやったことn選~プラグイン302個・コミッター271人を支えるために~
kenchan
5
1.5k
運用ダッシュボードの設計を誰も教えてくれないのだけどみなさんどうしてるんですか? - チームに監視するという文化を根付かせるための第一歩を踏みたい -
satoshi256kbyte
1
120
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
450
変わらないものが、変わるものを決める — 意図駆動開発 × イベントソーシング × イミュータブル | What Doesn't Change Decides What Can — IDD × Event Sourcing × Immutability
tomohisa
0
1.7k
仕様駆動開発の消費期限
watany
20
8.3k
Featured
See All Featured
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
470
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
760
Documentation Writing (for coders)
carmenintech
77
5.4k
It's Worth the Effort
3n
188
29k
A better future with KSS
kneath
240
18k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
250
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
ラッコキーワード サービス紹介資料
rakko
1
4.3M
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
240
Evolving SEO for Evolving Search Engines
ryanjones
0
250
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)