Skip to content

fix deprecated findDOMNode usage #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/react-bubble-chart-d3.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import * as d3 from 'd3';
export default class BubbleChart extends Component {
constructor(props){
super(props);
this.svg = React.createRef();

this.renderChart = this.renderChart.bind(this);
this.renderBubbles = this.renderBubbles.bind(this);
this.renderLegend = this.renderLegend.bind(this);
}

componentDidMount() {
this.svg = ReactDOM.findDOMNode(this);
this.renderChart();
}

Expand All @@ -33,7 +33,7 @@ export default class BubbleChart extends Component {
height,
} = this.props;
return (
<svg width={width} height={height} />
<svg width={width} height={height} ref={this.svg} />
)
}

Expand All @@ -49,10 +49,10 @@ export default class BubbleChart extends Component {
legendPercentage,
} = this.props;
// Reset the svg element to a empty state.
this.svg.innerHTML = '';
this.svg.current.innerHTML = '';
// Allow bubbles overflowing its SVG container in visual aspect if props(overflow) is true.
if(overflow)
this.svg.style.overflow = "visible";
this.svg.current.style.overflow = "visible";

const bubblesWidth = showLegend ? width * (1 - (legendPercentage / 100)) : width;
const legendWidth = width - bubblesWidth;
Expand Down Expand Up @@ -93,7 +93,7 @@ export default class BubbleChart extends Component {
labelFont,
} = this.props;

const bubbleChart = d3.select(this.svg).append("g")
const bubbleChart = d3.select(this.svg.current).append("g")
.attr("class", "bubble-chart")
.attr("transform", function(d) { return "translate(" + (width * graph.offsetX) + "," + (width * graph.offsetY) + ")"; });;

Expand Down Expand Up @@ -208,7 +208,7 @@ export default class BubbleChart extends Component {
const bubble = d3.select('.bubble-chart');
const bubbleHeight = bubble.node().getBBox().height;

const legend = d3.select(this.svg).append("g")
const legend = d3.select(this.svg.current).append("g")
.attr("transform", function() { return `translate(${offset},${(bubbleHeight)* 0.05})`; })
.attr("class", "legend");

Expand Down