Skip to content

Commit

Permalink
Chore(ReactVis): Remove Refs (#848)
Browse files Browse the repository at this point in the history
* Chore(ReactVis): Remove String Refs
  • Loading branch information
benshope authored Jun 30, 2018
1 parent 1f04561 commit 00ffe61
Show file tree
Hide file tree
Showing 15 changed files with 10 additions and 20 deletions.
1 change: 0 additions & 1 deletion showcase/examples/candlestick/candlestick.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class CandlestickSeries extends AbstractSeries {

return (
<g className={`${predefinedClassName} ${className}`}
ref={ref => (this.container = ref)}
transform={`translate(${marginLeft},${marginTop})`}>
{data.map((d, i) => {
const xTrans = xFunctor(d);
Expand Down
1 change: 0 additions & 1 deletion src/plot/axis/decorative-axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class DecorativeAxis extends AbstractSeries {

return (
<g className={`${predefinedClassName} ${className}`}
ref={ref => (this.container = ref)}
transform={`translate(${marginLeft},${marginTop})`}>
<line {...{
x1: x({x: axisStart.x}),
Expand Down
1 change: 0 additions & 1 deletion src/plot/series/arc-series.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ class ArcSeries extends AbstractSeries {
onMouseOut={this._seriesMouseOutHandler}
onClick={this._seriesClickHandler}
onContextMenu={this._seriesRightClickHandler}
ref={ref => (this.container = ref)}
opacity={hideSeries ? 0 : 1}
pointerEvents={disableSeries ? 'none' : 'all'}
transform={`translate(${marginLeft + x(center)},${marginTop + y(center)})`}>
Expand Down
1 change: 0 additions & 1 deletion src/plot/series/bar-series.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class BarSeries extends AbstractSeries {

return (
<g className={`${predefinedClassName} ${className}`}
ref={ref => (this.container = ref)}
transform={`translate(${marginLeft},${marginTop})`}>
{data.map((d, i) => {
const attrs = {
Expand Down
1 change: 0 additions & 1 deletion src/plot/series/contour-series.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class ContourSeries extends AbstractSeries {
.domain([min, max]).range(colorRange || CONTINUOUS_COLOR_RANGE);
return (
<g className={`${predefinedClassName} ${className}`}
ref={ref => (this.container = ref)}
transform={`translate(${marginLeft},${marginTop})`} >
{contouredData.map((polygon, index) => {
return (
Expand Down
1 change: 0 additions & 1 deletion src/plot/series/custom-svg-series.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ class CustomSVGSeries extends AbstractSeries {
});
return (
<g className={`${predefinedClassName} ${className}`}
ref={ref => (this.container = ref)}
transform={`translate(${marginLeft},${marginTop})`}>
{contents}
</g>
Expand Down
1 change: 0 additions & 1 deletion src/plot/series/heatmap-series.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class HeatmapSeries extends AbstractSeries {
return (
<g
className={`${predefinedClassName} ${className}`}
ref={ref => (this.container = ref)}
transform={`translate(${marginLeft},${marginTop})`}>
{data.map((d, i) => {
const attrs = {
Expand Down
1 change: 0 additions & 1 deletion src/plot/series/label-series.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class LabelSeries extends AbstractSeries {
return (
<g
className={`${predefinedClassName} ${className}`}
ref={ref => (this.container = ref)}
transform={`translate(${marginLeft},${marginTop})`}
style={style}
>
Expand Down
1 change: 0 additions & 1 deletion src/plot/series/mark-series.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ class MarkSeries extends AbstractSeries {
return (
<g
className={`${predefinedClassName} ${className}`}
ref={ref => (this.container = ref)}
transform={`translate(${marginLeft},${marginTop})`}
>
{data.map((d, i) => {
Expand Down
3 changes: 1 addition & 2 deletions src/plot/series/polygon-series.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ class PolygonSeries extends AbstractSeries {
fill: color || DEFAULT_COLOR,
style,
d: generatePath(data, xFunctor, yFunctor),
transform: `translate(${marginLeft},${marginTop})`,
ref: 'container'
transform: `translate(${marginLeft},${marginTop})`
}}/>
);
}
Expand Down
1 change: 0 additions & 1 deletion src/plot/series/rect-series.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class RectSeries extends AbstractSeries {

return (
<g className={`${predefinedClassName} ${className}`}
ref={ref => (this.container = ref)}
transform={`translate(${marginLeft},${marginTop})`}>
{data.map((d, i) => {
const attrs = {
Expand Down
1 change: 0 additions & 1 deletion src/plot/series/whisker-series.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ class WhiskerSeries extends AbstractSeries {

return (
<g className={`${predefinedClassName} ${className}`}
ref={ref => (this.container = ref)}
transform={`translate(${marginLeft},${marginTop})`}>
{data.map(renderWhiskerMark(whiskerMarkProps))}
</g>
Expand Down
14 changes: 9 additions & 5 deletions src/plot/xy-plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class XYPlot extends React.Component {
}
const seriesChildren = getSeriesChildren(children);
seriesChildren.forEach((child, index) => {
const component = this.refs[`series${index}`];
const component = this[`series${index}`];
if (component && component.onParentMouseDown) {
component.onParentMouseDown(event);
}
Expand All @@ -216,7 +216,7 @@ class XYPlot extends React.Component {
}
const seriesChildren = getSeriesChildren(children);
seriesChildren.forEach((child, index) => {
const component = this.refs[`series${index}`];
const component = this[`series${index}`];
if (component && component.onParentMouseMove) {
component.onParentMouseMove(event);
}
Expand Down Expand Up @@ -259,7 +259,7 @@ class XYPlot extends React.Component {
}
const seriesChildren = getSeriesChildren(children);
seriesChildren.forEach((child, index) => {
const component = this.refs[`series${index}`];
const component = this[`series${index}`];
if (component && component.onParentTouchStart) {
component.onParentTouchStart(event);
}
Expand All @@ -278,7 +278,7 @@ class XYPlot extends React.Component {
}
const seriesChildren = getSeriesChildren(children);
seriesChildren.forEach((child, index) => {
const component = this.refs[`series${index}`];
const component = this[`series${index}`];
if (component && component.onParentTouchMove) {
component.onParentTouchMove(event);
}
Expand Down Expand Up @@ -442,6 +442,11 @@ class XYPlot extends React.Component {
return React.cloneElement(child, {
...dimensions,
animation,
ref: (ref) => {
if (dataProps) {
this[`series${seriesProps[index].seriesIndex}`] = ref;
}
},
...seriesProps[index],
...scaleMixins,
...child.props,
Expand Down Expand Up @@ -498,7 +503,6 @@ class XYPlot extends React.Component {
);
}
const components = this._getClonedChildComponents();

return (
<div
style={{
Expand Down
1 change: 0 additions & 1 deletion src/utils/series-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ export function getSeriesPropsFromChildren(children) {
props = {
...seriesTypeInfo,
seriesIndex,
ref: `series${seriesIndex}`,
_colorValue,
_opacityValue
};
Expand Down
1 change: 0 additions & 1 deletion tests/utils/series-utils-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ test('series-utils #getSeriesChildren', t => {
const arePropsValid = seriesProps => {
return typeof seriesProps._colorValue !== 'undefined' &&
typeof seriesProps._opacityValue !== 'undefined' &&
typeof seriesProps.ref === 'string' &&
typeof seriesProps.sameTypeIndex === 'number' &&
typeof seriesProps.sameTypeTotal === 'number' &&
typeof seriesProps.seriesIndex === 'number';
Expand Down

0 comments on commit 00ffe61

Please sign in to comment.