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
bootcamp2025_バックエンド研修_WebAPIサーバ作成.pdf
geniee_inc
0
130
Server Side Kotlin Meetup vol.16: 内部動作を理解して ハイパフォーマンスなサーバサイド Kotlin アプリケーションを書こう
ternbusty
3
250
What's new in Spring Modulith?
olivergierke
1
170
TransformerからMCPまで(現代AIを理解するための羅針盤)
mickey_kubo
7
5.4k
ALL CODE BASE ARE BELONG TO STUDY
uzulla
28
6.7k
チームの境界をブチ抜いていけ
tokai235
0
230
20251016_Rails News ~Rails 8.1の足音を聴く~
morimorihoge
3
840
Amazon Verified Permissions実践入門 〜Cedar活用とAppSync導入事例/Practical Introduction to Amazon Verified Permissions
fossamagna
2
100
なぜGoのジェネリクスはこの形なのか? - Featherweight Goが明かす設計の核心
qualiarts
0
260
React Nativeならぬ"Vue Native"が実現するかも?_新世代マルチプラットフォーム開発フレームワークのLynxとLynxのVue.js対応を追ってみよう_Vue Lynx
yut0naga1_fa
2
1.6k
CSC305 Lecture 11
javiergs
PRO
0
280
AI 駆動開発におけるコミュニティと AWS CDK の価値
konokenj
5
260
Featured
See All Featured
Code Review Best Practice
trishagee
72
19k
Building an army of robots
kneath
305
46k
The Illustrated Children's Guide to Kubernetes
chrisshort
49
51k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.7k
The Cost Of JavaScript in 2023
addyosmani
55
9.1k
Product Roadmaps are Hard
iamctodd
PRO
55
11k
Docker and Python
trallard
46
3.6k
The Language of Interfaces
destraynor
162
25k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
34
2.3k
For a Future-Friendly Web
brad_frost
180
10k
Context Engineering - Making Every Token Count
addyosmani
8
300
Designing for humans not robots
tammielis
254
26k
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)