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
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
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
170
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
21
6.9k
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
890
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
120
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
370
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
210
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
600
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
210
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.7k
AIで効率化できた業務・日常
ochtum
0
140
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.2k
Creating Composable Callables in Contemporary C++
rollbear
0
160
Featured
See All Featured
Optimizing for Happiness
mojombo
378
71k
GitHub's CSS Performance
jonrohan
1033
470k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
200
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.3k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Code Reviewing Like a Champion
maltzj
528
40k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
210
The agentic SEO stack - context over prompts
schlessera
0
820
Producing Creativity
orderedlist
PRO
348
40k
Into the Great Unknown - MozCon
thekraken
41
2.6k
Building AI with AI
inesmontani
PRO
1
1.1k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
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)