Skip to content
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

Run manual-bind-to-arrow Codemod #963

Merged
merged 4 commits into from
Oct 15, 2018
Merged
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions showcase/axes/dynamic-complex-edge-hints.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,11 @@ export default class Example extends React.Component {
this.state = {
value: null
};
this._rememberValue = this._rememberValue.bind(this);
}

_rememberValue(value) {
_rememberValue = value => {
this.setState({value});
}
};

render() {
const {value} = this.state;
Expand Down
11 changes: 4 additions & 7 deletions showcase/axes/dynamic-crosshair.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,25 @@ export default class DynamicCrosshair extends React.Component {
this.state = {
crosshairValues: []
};

this._onMouseLeave = this._onMouseLeave.bind(this);
this._onNearestX = this._onNearestX.bind(this);
}

/**
* Event handler for onMouseLeave.
* @private
*/
_onMouseLeave() {
_onMouseLeave = () => {
this.setState({crosshairValues: []});
}
};

/**
* Event handler for onNearestX.
* @param {Object} value Selected value.
* @param {index} index Index of the value in the data array.
* @private
*/
_onNearestX(value, {index}) {
_onNearestX = (value, {index}) => {
this.setState({crosshairValues: DATA.map(d => d[index])});
}
};

render() {
return (
Expand Down
10 changes: 4 additions & 6 deletions showcase/axes/dynamic-hints.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,17 @@ export default class Example extends React.Component {
this.state = {
value: null
};
this._rememberValue = this._rememberValue.bind(this);
this._forgetValue = this._forgetValue.bind(this);
}

_forgetValue() {
_forgetValue = () => {
this.setState({
value: null
});
}
};

_rememberValue(value) {
_rememberValue = value => {
this.setState({value});
}
};

render() {
const {value} = this.state;
Expand Down
5 changes: 2 additions & 3 deletions showcase/axes/dynamic-programmatic-rightedge-hints.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ export default class Example extends React.Component {
this.state = {
value: null
};
this._rememberValue = this._rememberValue.bind(this);
}

_rememberValue(value) {
_rememberValue = value => {
this.setState({value});
}
};

render() {
const {value} = this.state;
Expand Down
5 changes: 2 additions & 3 deletions showcase/axes/dynamic-simple-edge-hints.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,11 @@ export default class Example extends React.Component {
this.state = {
value: null
};
this._rememberValue = this._rememberValue.bind(this);
}

_rememberValue(value) {
_rememberValue = value => {
this.setState({value});
}
};

render() {
const {value} = this.state;
Expand Down
5 changes: 2 additions & 3 deletions showcase/axes/dynamic-simple-topedge-hints.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ export default class Example extends React.Component {
this.state = {
value: null
};
this._rememberValue = this._rememberValue.bind(this);
}

_rememberValue(value) {
_rememberValue = value => {
this.setState({value});
}
};

render() {
const {value} = this.state;
Expand Down
7 changes: 4 additions & 3 deletions showcase/interaction/interaction-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,12 @@ export class LinkedCharts extends Component {
constructor() {
super();
this.state = {index: null};
this.handleMouseOver = this.handleMouseOver.bind(this);
}
handleMouseOver(index) {

handleMouseOver = index => {
this.setState({index});
}
};

render() {
const {index} = this.state;
return (
Expand Down
10 changes: 4 additions & 6 deletions showcase/legends/searchable-discrete-color.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,17 @@ export default class Example extends React.Component {
],
searchText: ''
};
this._clickHandler = this._clickHandler.bind(this);
this._searchChangeHandler = this._searchChangeHandler.bind(this);
}

_clickHandler(item) {
_clickHandler = item => {
const {items} = this.state;
item.disabled = !item.disabled;
this.setState({items});
}
};

_searchChangeHandler(searchText) {
_searchChangeHandler = searchText => {
this.setState({searchText});
}
};

render() {
const {items, searchText} = this.state;
Expand Down
5 changes: 2 additions & 3 deletions showcase/misc/synced-charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export default class Example extends React.Component {
this.state = {
selectedIndex: null
};
this._onChartMouseLeave = this._onChartMouseLeave.bind(this);
this._onSeriesMouseOvers = [
this._onSeriesMouseOver.bind(this, 0),
this._onSeriesMouseOver.bind(this, 1)
Expand All @@ -50,9 +49,9 @@ export default class Example extends React.Component {
return null;
}

_onChartMouseLeave() {
_onChartMouseLeave = () => {
this.setState({selectedIndex: null});
}
};

_onSeriesMouseOver(selectedIndex) {
this.setState({selectedIndex});
Expand Down
30 changes: 12 additions & 18 deletions showcase/plot/complex-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@ export default class Example extends React.Component {
}
]
};
this._nearestXHandler = this._nearestXHandler.bind(this);
this._mouseLeaveHandler = this._mouseLeaveHandler.bind(this);
this._updateButtonClicked = this._updateButtonClicked.bind(this);
this._legendClickHandler = this._legendClickHandler.bind(this);
this._formatCrosshairItems = this._formatCrosshairItems.bind(this);
this._formatCrosshairTitle = this._formatCrosshairTitle.bind(this);
}

/**
Expand All @@ -87,70 +81,70 @@ export default class Example extends React.Component {
* @returns {Array<Object>} Array of objects with titles and values.
* @private
*/
_formatCrosshairItems(values) {
_formatCrosshairItems = values => {
const {series} = this.state;
return values.map((v, i) => {
return {
title: series[i].title,
value: v.top
};
});
}
};

/**
* Format the title line of the crosshair.
* @param {Array} values Array of values.
* @returns {Object} The caption and the value of the title.
* @private
*/
_formatCrosshairTitle(values) {
_formatCrosshairTitle = values => {
return {
title: 'X',
value: values[0].left
};
}
};

/**
* Click handler for the legend.
* @param {Object} item Clicked item of the legend.
* @param {number} i Index of the legend.
* @private
*/
_legendClickHandler(item, i) {
_legendClickHandler = (item, i) => {
const {series} = this.state;
series[i].disabled = !series[i].disabled;
this.setState({series});
}
};

/**
* Event handler for onMouseLeave.
* @private
*/
_mouseLeaveHandler() {
_mouseLeaveHandler = () => {
this.setState({crosshairValues: []});
}
};

/**
* Event handler for onNearestX.
* @param {Object} value Selected value.
* @param {number} index Index of the series.
* @private
*/
_nearestXHandler(value, {index}) {
_nearestXHandler = (value, {index}) => {
const {series} = this.state;
this.setState({
crosshairValues: series.map(s => s.data[index])
});
}
};

_updateButtonClicked() {
_updateButtonClicked = () => {
const {series} = this.state;
const totalValues = Math.random() * 50;
series.forEach(s => {
s.data = getRandomSeriesData(totalValues);
});
this.setState({series});
}
};

render() {
const {series, crosshairValues} = this.state;
Expand Down
5 changes: 2 additions & 3 deletions showcase/showcase-components/showcase-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ class ShowcaseDropdown extends React.Component {
this.state = {
open: false
};
this.toggleState = this.toggleState.bind(this);
}

toggleState() {
toggleState = () => {
this.setState({open: !this.state.open});
}
};

render() {
const {items} = this.props;
Expand Down
10 changes: 4 additions & 6 deletions src/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ class Animation extends PureComponent {
constructor(props) {
super(props);
this._updateInterpolator(props);
this._renderChildren = this._renderChildren.bind(this);
this._motionEndHandler = this._motionEndHandler.bind(this);
}

componentWillUpdate(props) {
Expand All @@ -68,19 +66,19 @@ class Animation extends PureComponent {
}
}

_motionEndHandler() {
_motionEndHandler = () => {
if (this.props.onEnd) {
this.props.onEnd();
}
}
};

/**
* Render the child into the parent.
* @param {Number} i Number generated by the spring.
* @returns {React.Component} Rendered react element.
* @private
*/
_renderChildren({i}) {
_renderChildren = ({i}) => {
const {children} = this.props;
const interpolator = this._interpolator;
const child = React.Children.only(children);
Expand Down Expand Up @@ -109,7 +107,7 @@ class Animation extends PureComponent {
// enforce re-rendering
_animation: Math.random()
});
}
};

/**
* Update the interpolator function and assign it to this._interpolator.
Expand Down
5 changes: 2 additions & 3 deletions src/make-vis-flexible.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,13 @@ function makeFlexible(Component, isWidthFlexible, isHeightFlexible) {
height: 0,
width: 0
};
this._onResize = this._onResize.bind(this);
}

/**
* Get the width of the container and assign the width.
* @private
*/
_onResize() {
_onResize = () => {
const containerElement = getDOMNode(this[CONTAINER_REF]);
const {offsetHeight, offsetWidth} = containerElement;

Expand All @@ -134,7 +133,7 @@ function makeFlexible(Component, isWidthFlexible, isHeightFlexible) {
...newHeight,
...newWidth
});
}
};

componentDidMount() {
this._onResize();
Expand Down
Loading