Skip to content

Commit 6d4819f

Browse files
author
Oliver Caldwell
committed
Define faux node outside of d3.select
This fixes the issue where the root node vanished, odd.
1 parent fba0034 commit 6d4819f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

js/d3-to-react-again/main.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ var Chart = React.createClass({
3232
.x(function (d) { return x(d.date) })
3333
.y(function (d) { return y(d.close) })
3434

35-
var svg = d3.select(ReactFauxDOM.createElement('svg'))
35+
var node = ReactFauxDOM.createElement('svg')
36+
var svg = d3.select(node)
3637
.attr('width', width + margin.left + margin.right)
3738
.attr('height', height + margin.top + margin.bottom)
3839
.append('g')
@@ -66,7 +67,7 @@ var Chart = React.createClass({
6667
.attr('class', 'line')
6768
.attr('d', line)
6869

69-
return svg.node().toReact()
70+
return node.toReact()
7071
}
7172
})
7273

0 commit comments

Comments
 (0)