From 20e448fc0adae4c7cb237a2a796a6f1000ccc551 Mon Sep 17 00:00:00 2001 From: Felix Linker Date: Tue, 29 Dec 2020 16:39:18 +0100 Subject: [PATCH] Optimize constructors --- src/app/components/AvailableModulesMenu.jsx | 4 ++-- src/app/components/LineChart.jsx | 9 ++------- src/app/components/ModalHelp.jsx | 8 -------- src/app/components/ShipPicker.jsx | 2 +- 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/app/components/AvailableModulesMenu.jsx b/src/app/components/AvailableModulesMenu.jsx index 756bf957..3ae83a43 100644 --- a/src/app/components/AvailableModulesMenu.jsx +++ b/src/app/components/AvailableModulesMenu.jsx @@ -7,6 +7,7 @@ import { MountFixed, MountGimballed, MountTurret } from './SvgIcons'; import FuzzySearch from 'react-fuzzy'; import { getModuleInfo } from 'ed-forge/lib/data/items'; import { groupBy, mapValues, sortBy } from 'lodash'; +import autoBind from 'auto-bind'; const PRESS_THRESHOLD = 500; // mouse/touch down threshold @@ -36,8 +37,7 @@ export default class AvailableModulesMenu extends TranslatedComponent { */ constructor(props, context) { super(props); - this._hideDiff = this._hideDiff.bind(this); - this._showSearch = this._showSearch.bind(this); + autoBind(this); this.state = this._initState(props, context); } diff --git a/src/app/components/LineChart.jsx b/src/app/components/LineChart.jsx index f9655554..0eee53ca 100644 --- a/src/app/components/LineChart.jsx +++ b/src/app/components/LineChart.jsx @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import ContainerDimensions from 'react-container-dimensions'; import * as d3 from 'd3'; import TranslatedComponent from './TranslatedComponent'; +import autoBind from 'auto-bind'; const MARGIN = { top: 15, right: 20, bottom: 35, left: 60 }; @@ -44,13 +45,7 @@ export default class LineChart extends TranslatedComponent { */ constructor(props, context) { super(props); - - this._updateDimensions = this._updateDimensions.bind(this); - this._updateSeries = this._updateSeries.bind(this); - this._tooltip = this._tooltip.bind(this); - this._showTip = this._showTip.bind(this); - this._hideTip = this._hideTip.bind(this); - this._moveTip = this._moveTip.bind(this); + autoBind(this); const series = props.series; diff --git a/src/app/components/ModalHelp.jsx b/src/app/components/ModalHelp.jsx index 156a5348..a0b1e57e 100644 --- a/src/app/components/ModalHelp.jsx +++ b/src/app/components/ModalHelp.jsx @@ -11,14 +11,6 @@ export default class ModalHelp extends TranslatedComponent { title: PropTypes.string }; - /** - * Constructor - * @param {Object} props React Component properties - */ - constructor(props) { - super(props); - } - /** * Render the modal * @return {React.Component} Modal Content diff --git a/src/app/components/ShipPicker.jsx b/src/app/components/ShipPicker.jsx index 3b07c2d1..f91b286c 100644 --- a/src/app/components/ShipPicker.jsx +++ b/src/app/components/ShipPicker.jsx @@ -27,7 +27,7 @@ export default class ShipPicker extends TranslatedComponent { * @param {object} props Properties react * @param {object} context react context */ - constructor(props, context) { // eslint-disable-line + constructor(props, context) { super(props); autoBind(this); this.state = { menuOpen: false };