Replace manual bind(this) calls with auto-bind

This commit is contained in:
felixlinker
2020-08-09 17:41:15 +02:00
parent 16ef7ea389
commit cf72bd11a8
6 changed files with 11 additions and 17 deletions

View File

@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import TranslatedComponent from './TranslatedComponent';
import autoBind from 'auto-bind';
/**
* Boost displays a boost button that toggles bosot
@@ -21,10 +22,7 @@ export default class Boost extends TranslatedComponent {
*/
constructor(props, context) {
super(props);
const { ship, boost } = props;
this._keyDown = this._keyDown.bind(this);
this._toggleBoost = this._toggleBoost.bind(this);
autoBind(this);
}
/**

View File

@@ -2,6 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import TranslatedComponent from './TranslatedComponent';
import Slider from '../components/Slider';
import autoBind from 'auto-bind';
/**
* Cargo slider
@@ -21,8 +22,7 @@ export default class Cargo extends TranslatedComponent {
*/
constructor(props, context) {
super(props);
this._cargoChange = this._cargoChange.bind(this);
autoBind(this);
}
/**

View File

@@ -2,6 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import TranslatedComponent from './TranslatedComponent';
import Slider from '../components/Slider';
import autoBind from 'auto-bind';
/**
* Fuel slider
@@ -21,8 +22,7 @@ export default class Fuel extends TranslatedComponent {
*/
constructor(props, context) {
super(props);
this._fuelChange = this._fuelChange.bind(this);
autoBind(this);
}
/**

View File

@@ -5,6 +5,7 @@ import * as Calc from '../shipyard/Calculations';
import PieChart from './PieChart';
import { nameComparator } from '../utils/SlotFunctions';
import { MountFixed, MountGimballed, MountTurret } from './SvgIcons';
import autoBind from 'auto-bind';
/**
* Generates an internationalization friendly weapon comparator that will

View File

@@ -11,6 +11,7 @@ import Movement from './Movement';
import Offence from './Offence';
import Defence from './Defence';
import WeaponDamageChart from './WeaponDamageChart';
import autoBind from 'auto-bind';
/**
* Outfitting subpages
@@ -42,10 +43,7 @@ export default class OutfittingSubpages extends TranslatedComponent {
*/
constructor(props) {
super(props);
this._powerTab = this._powerTab.bind(this);
this._profilesTab = this._profilesTab.bind(this);
this._offenceTab = this._offenceTab.bind(this);
this._defenceTab = this._defenceTab.bind(this);
autoBind(this);
this.state = {
tab: Persist.getOutfittingTab() || 'power',

View File

@@ -5,6 +5,7 @@ import { Ships } from 'coriolis-data/dist';
import { Rocket } from './SvgIcons';
import Persist from '../stores/Persist';
import cn from 'classnames';
import autoBind from 'auto-bind';
/**
* Ship picker
@@ -28,11 +29,7 @@ export default class ShipPicker extends TranslatedComponent {
*/
constructor(props, context) { // eslint-disable-line
super(props);
this.shipOrder = Object.keys(Ships).sort();
this._toggleMenu = this._toggleMenu.bind(this);
this._closeMenu = this._closeMenu.bind(this);
autoBind(this);
this.state = { menuOpen: false };
}