Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

fix `react/jsx-no-bind` errors

Jason Kenteb8eddef6438
diff --git a/.eslintrc b/.eslintrc
index 81fda8f83..e1df34d3e 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -115,9 +115,8 @@
"jsx-a11y/click-events-have-key-events": "off",
// React rules overrides
- "react/jsx-props-no-spreading": "off",
+ "react/jsx-props-no-spreading": "warn",
"react/jsx-filename-extension": "off",
- "react/jsx-no-bind": "off", // 37 warnings
"react/prefer-stateless-function": "warn", // 20 errors, consider fixing
"react/sort-comp": "off",
"react/no-unused-state": "warn", // 38 errors
diff --git a/web/js/components/animation-widget/gif-panel.js b/web/js/components/animation-widget/gif-panel.js
index c4a00d108..d89832712 100644
--- a/web/js/components/animation-widget/gif-panel.js
+++ b/web/js/components/animation-widget/gif-panel.js
@@ -64,7 +64,7 @@ export default class GifPanel extends React.Component {
optionArray={this.state.resolutions}
value={this.state.resolution}
optionName="resolution"
- onChange={this.handleChange.bind(this)}
+ onChange={this.handleChange}
/>
</div>
<GifPanelGrid
diff --git a/web/js/components/compare/opacity-slider.js b/web/js/components/compare/opacity-slider.js
index 525ec0c23..74e8d33cb 100644
--- a/web/js/components/compare/opacity-slider.js
+++ b/web/js/components/compare/opacity-slider.js
@@ -20,7 +20,8 @@ class OpacitySlider extends React.Component {
this.state = {
value: props.value,
};
- this.debounceOpacityUpdate = lodashDebounce(this.onSlide.bind(this), 100);
+ this.onSlide = this.onSlide.bind(this);
+ this.debounceOpacityUpdate = lodashDebounce(this.onSlide, 100);
}
/*
@@ -48,7 +49,7 @@ class OpacitySlider extends React.Component {
defaultValue={this.state.value}
tipFormatter={percentFormatter}
onChange={this.debounceOpacityUpdate}
- onAfterChange={this.onSlide.bind(this)}
+ onAfterChange={this.onSlide}
/>
</div>
<label className="wv-slider-label right">
diff --git a/web/js/components/feature-alert/geostationary-modal.js b/web/js/components/feature-alert/geostationary-modal.js
index 2dfe33aab..7c22a2376 100644
--- a/web/js/components/feature-alert/geostationary-modal.js
+++ b/web/js/components/feature-alert/geostationary-modal.js
@@ -10,6 +10,11 @@ import {
import { history } from '../../main';
class GeostationaryModalBody extends React.Component {
+ constructor(props) {
+ super(props);
+ this.tryIt = this.tryIt.bind(this);
+ }
+
tryIt() {
const { isMobile, prepareAnimate, closeModal } = this.props;
prepareAnimate(isMobile);
@@ -66,7 +71,7 @@ class GeostationaryModalBody extends React.Component {
<Button
className="btn btn-lg"
- onClick={this.tryIt.bind(this)}
+ onClick={this.tryIt}
>
Try it!
</Button>
diff --git a/web/js/components/image-download/panel.js b/web/js/components/image-download/panel.js
index edec39974..779203511 100644
--- a/web/js/components/image-download/panel.js
+++ b/web/js/components/image-download/panel.js
@@ -40,6 +40,8 @@ export default class ImageResSelection extends React.Component {
valid: props.valid,
debugUrl: '',
};
+ this.handleChange = this.handleChange.bind(this);
+ this.onDownload = this.onDownload.bind(this);
}
onDownload(width, height) {
@@ -108,7 +110,7 @@ export default class ImageResSelection extends React.Component {
optionName="filetype"
value={this.state.fileType}
optionArray={this.props.fileTypes}
- onChange={this.handleChange.bind(this)}
+ onChange={this.handleChange}
/>
{this.props.secondLabel}
</div>
@@ -165,7 +167,7 @@ export default class ImageResSelection extends React.Component {
optionArray={resolutions}
value={resolution}
optionName="resolution"
- onChange={this.handleChange.bind(this)}
+ onChange={this.handleChange}
/>
{this.props.firstLabel}
</div>
@@ -178,7 +180,7 @@ export default class ImageResSelection extends React.Component {
maxImageSize={maxImageSize}
validSize={imageSizeValid(height, width, MAX_DIMENSION_SIZE)}
validLayers={layerList.length > 0}
- onClick={this.onDownload.bind(this)}
+ onClick={this.onDownload}
/>
</div>
);
diff --git a/web/js/components/layer/product-picker/header.js b/web/js/components/layer/product-picker/header.js
index e2a5fe0a8..f34d150ac 100644
--- a/web/js/components/layer/product-picker/header.js
+++ b/web/js/components/layer/product-picker/header.js
@@ -27,6 +27,8 @@ class ProductPickerHeader extends React.Component {
this.state = {
inputValue: props.inputValue,
};
+ this.revertToInitialScreen = this.revertToInitialScreen.bind(this);
+ this.handleChange = this.handleChange.bind(this);
}
componentDidMount() {
@@ -75,7 +77,7 @@ class ProductPickerHeader extends React.Component {
tag="a"
title="Back to Layer Categories"
href="#"
- onClick={this.revertToInitialScreen.bind(this)}
+ onClick={this.revertToInitialScreen}
>
Categories
</BreadcrumbItem>
@@ -94,7 +96,7 @@ class ProductPickerHeader extends React.Component {
<Button
className="back-button"
color="secondary"
- onClick={this.revertToInitialScreen.bind(this)}
+ onClick={this.revertToInitialScreen}
>
<FontAwesomeIcon icon={faArrowLeft} />
</Button>
@@ -118,7 +120,7 @@ class ProductPickerHeader extends React.Component {
)}
<Input
- onChange={this.handleChange.bind(this)}
+ onChange={this.handleChange}
id="layers-search-input"
value={this.state.inputValue}
placeholder="Search"
diff --git a/web/js/components/layer/product-picker/layer-metadata-detail.js b/web/js/components/layer/product-picker/layer-metadata-detail.js
index ead425e78..6bea3e080 100644
--- a/web/js/components/layer/product-picker/layer-metadata-detail.js
+++ b/web/js/components/layer/product-picker/layer-metadata-detail.js
@@ -13,6 +13,7 @@ class LayerMetadataDetail extends React.Component {
this.state = {
isDateRangesExpanded: false,
};
+ this.toggleLayer = this.toggleLayer.bind(this);
}
toggleLayer() {
@@ -174,7 +175,7 @@ class LayerMetadataDetail extends React.Component {
</div>
)}
<div className="text-center">
- <Button className={btnClass} onClick={this.toggleLayer.bind(this)}>
+ <Button className={btnClass} onClick={this.toggleLayer}>
<FontAwesomeIcon icon={btnIconClass} />
{buttonText}
</Button>
diff --git a/web/js/components/layer/product-picker/measurement-layer-row.js b/web/js/components/layer/product-picker/measurement-layer-row.js
index d7d9cf912..ac6cdd3c8 100644
--- a/web/js/components/layer/product-picker/measurement-layer-row.js
+++ b/web/js/components/layer/product-picker/measurement-layer-row.js
@@ -19,6 +19,8 @@ class MeasurementLayerRow extends React.Component {
checked: props.checked,
tooltipOpen: false,
};
+ this.onClick = this.onClick.bind(this);
+ this.toggleTooltip = this.toggleTooltip.bind(this);
}
onClick() {
@@ -54,13 +56,13 @@ class MeasurementLayerRow extends React.Component {
return (
<ListGroupItem
key={`${measurementId}-${layer.id}`}
- onClick={this.onClick.bind(this)}
+ onClick={this.onClick}
id={itemElementId}
className={listItemClass}
>
<Checkbox
name={title}
- onClick={this.onClick.bind(this)}
+ onClick={this.onClick}
checked={checked}
label={title}
classNames="settings-check"
@@ -73,7 +75,7 @@ class MeasurementLayerRow extends React.Component {
placement="top"
isOpen={tooltipOpen}
target={itemElementId}
- toggle={this.toggleTooltip.bind(this)}
+ toggle={this.toggleTooltip}
>
This layer has no visible content on the selected date:
{' '}
diff --git a/web/js/components/layer/product-picker/product-picker.js b/web/js/components/layer/product-picker/product-picker.js
index 9ef8fce16..fa6772f38 100644
--- a/web/js/components/layer/product-picker/product-picker.js
+++ b/web/js/components/layer/product-picker/product-picker.js
@@ -55,6 +55,12 @@ class ProductPicker extends React.Component {
listScrollTop: props.listScrollTop || 0,
};
this.runSearch = lodashDebounce(this.runSearch, 300);
+ this.revertSearchState = this.revertSearchState.bind(this);
+ this.showMetadataForLayer = this.showMetadataForLayer.bind(this);
+ this.updateSelectedMeasurement = this.updateSelectedMeasurement.bind(this);
+ this.toggleFilterByAvailable = this.toggleFilterByAvailable.bind(this);
+ this.drawMeasurements = this.drawMeasurements.bind(this);
+ this.sort = this.sort.bind(this);
}
componentDidMount() {
@@ -360,7 +366,7 @@ class ProductPicker extends React.Component {
hasMeasurementSource={hasMeasurementSource}
measurementConfig={measurementConfig}
selectedMeasurement={selectedMeasurement}
- updateSelectedMeasurement={this.updateSelectedMeasurement.bind(this)}
+ updateSelectedMeasurement={this.updateSelectedMeasurement}
showMetadataForLayer={(layer) => this.showMetadataForLayer(layer)}
setSourceIndex={(index) => this.setSourceIndex(index)}
selectedMeasurementSourceIndex={selectedMeasurementSourceIndex}
@@ -382,7 +388,7 @@ class ProductPicker extends React.Component {
{numRowsFilteredOut}
{' '}
result(s) are being filtered out.
- <a className="remove-filters" onClick={this.toggleFilterByAvailable.bind(this)}>
+ <a className="remove-filters" onClick={this.toggleFilterByAvailable}>
Remove filters?
</a>
</p>
@@ -423,7 +429,7 @@ class ProductPicker extends React.Component {
removeLayer={removeLayer}
selectedProjection={selectedProjection}
showPreviewImage={showPreviewImage}
- showMetadataForLayer={this.showMetadataForLayer.bind(this)}
+ showMetadataForLayer={this.showMetadataForLayer}
/>
</Scrollbars>
</div>
@@ -484,10 +490,10 @@ class ProductPicker extends React.Component {
category={category}
modalView={modalView}
width={width}
- runSearch={this.runSearch.bind(this)}
- updateListState={this.revertSearchState.bind(this)}
+ runSearch={this.runSearch}
+ updateListState={this.revertSearchState}
filterByAvailable={filterByAvailable}
- toggleFilterByAvailable={this.toggleFilterByAvailable.bind(this)}
+ toggleFilterByAvailable={this.toggleFilterByAvailable}
>
{listType === 'search' && !isMobile
&& (
@@ -496,7 +502,7 @@ class ProductPicker extends React.Component {
<FilterUnavailable
selectedDate={selectedDate}
filterByAvailable={filterByAvailable}
- toggleFilterByAvailable={this.toggleFilterByAvailable.bind(this)}
+ toggleFilterByAvailable={this.toggleFilterByAvailable}
/>
</div>
<div className="results-text">
@@ -532,7 +538,7 @@ class ProductPicker extends React.Component {
className="layer-category-navigation"
active={sortKey === categoryType}
>
- <NavLink onClick={this.sort.bind(this, sortKey)}>
+ <NavLink onClick={() => this.sort(sortKey)}>
{sortKey === 'scientific' ? 'Science Disciplines' : sortKey}
</NavLink>
</NavItem>
@@ -544,7 +550,7 @@ class ProductPicker extends React.Component {
<CategoryGrid
categories={lodashValues(categoryConfig[categoryType])}
measurementConfig={measurementConfig}
- drawMeasurements={this.drawMeasurements.bind(this)}
+ drawMeasurements={this.drawMeasurements}
hasMeasurementSource={hasMeasurementSource}
categoryType={categoryType}
width={width}
diff --git a/web/js/components/layer/settings/palette-threshold.js b/web/js/components/layer/settings/palette-threshold.js
index a9bb4d065..1e4d93a93 100644
--- a/web/js/components/layer/settings/palette-threshold.js
+++ b/web/js/components/layer/settings/palette-threshold.js
@@ -15,6 +15,8 @@ class ThresholdSelect extends React.Component {
activeDragger: 'start',
};
this.debounceSetRange = lodashDebounce(props.setRange, 300);
+ this.updateSquash = this.updateSquash.bind(this);
+ this.updateThreshold = this.updateThreshold.bind(this);
}
/**
@@ -106,7 +108,7 @@ class ThresholdSelect extends React.Component {
label="Squash Palette"
classNames="wv-squash-button-check"
id={`wv-squash-button-check${index}`}
- onCheck={this.updateSquash.bind(this)}
+ onCheck={this.updateSquash}
/>
</div>
<div
@@ -117,7 +119,7 @@ class ThresholdSelect extends React.Component {
defaultValue={[start, end]}
min={min}
max={max}
- onChange={this.updateThreshold.bind(this)}
+ onChange={this.updateThreshold}
/>
<div className="wv-label">
<span className="wv-label-range-min wv-label-range">
diff --git a/web/js/components/layer/settings/vector-filter.js b/web/js/components/layer/settings/vector-filter.js
index aee4560b7..be8035f43 100644
--- a/web/js/components/layer/settings/vector-filter.js
+++ b/web/js/components/layer/settings/vector-filter.js
@@ -12,6 +12,7 @@ class VectorFilter extends React.Component {
activeDragger: 'start',
};
this.debounceSetRange = lodashDebounce(props.setFilterRange, 300);
+ this.updateFilter = this.updateFilter.bind(this);
}
/**
@@ -66,7 +67,7 @@ class VectorFilter extends React.Component {
defaultValue={[start, end]}
min={min}
max={max}
- onChange={this.updateFilter.bind(this)}
+ onChange={this.updateFilter}
/>
<div className="wv-label">
<span className="wv-label-range-min wv-label-range">
diff --git a/web/js/components/measure-tool/measure-menu.js b/web/js/components/measure-tool/measure-menu.js
index 5f28eb5fa..0f926b8f9 100644
--- a/web/js/components/measure-tool/measure-menu.js
+++ b/web/js/components/measure-tool/measure-menu.js
@@ -37,6 +37,8 @@ class MeasureMenu extends Component {
tooltipOpen: false,
};
this.tooltipToggle = this.tooltipToggle.bind(this);
+ this.triggerEvent = this.triggerEvent.bind(this);
+ this.unitToggle = this.unitToggle.bind(this);
}
triggerEvent(eventName) {
@@ -68,7 +70,7 @@ class MeasureMenu extends Component {
id="unit-toggle"
className="custom-control-input"
type="checkbox"
- onChange={this.unitToggle.bind(this)}
+ onChange={this.unitToggle}
defaultChecked={this.props.units === 'mi'}
/>
<label className="custom-control-label" htmlFor="unit-toggle">
@@ -78,7 +80,7 @@ class MeasureMenu extends Component {
</Form>
<IconList
list={OPTIONS_ARRAY}
- onClick={this.triggerEvent.bind(this)}
+ onClick={this.triggerEvent}
size={listSize}
/>
</>
diff --git a/web/js/containers/gif.js b/web/js/containers/gif.js
index f411fad8e..c3932dc6f 100644
--- a/web/js/containers/gif.js
+++ b/web/js/containers/gif.js
@@ -56,6 +56,8 @@ class GIF extends Component {
};
this.onBoundaryChange = this.onBoundaryChange.bind(this);
this.onGifProgress = this.onGifProgress.bind(this);
+ this.createGIF = this.createGIF.bind(this);
+ this.toggleShowDates = this.toggleShowDates.bind(this);
}
componentDidMount() {
@@ -130,8 +132,8 @@ class GIF extends Component {
lonlats={lonlats}
startDate={startDate}
endDate={endDate}
- onClick={this.createGIF.bind(this)}
- onCheck={this.toggleShowDates.bind(this)}
+ onClick={this.createGIF}
+ onCheck={this.toggleShowDates}
numberOfFrames={numberOfFrames}
/>
diff --git a/web/js/containers/projection.js b/web/js/containers/projection.js
index 6a21e6689..0a7f2893a 100644
--- a/web/js/containers/projection.js
+++ b/web/js/containers/projection.js
@@ -41,6 +41,11 @@ const getInfoArray = function(projArray) {
}));
};
class ProjectionList extends Component {
+ constructor(props) {
+ super(props);
+ this.updateProjection = this.updateProjection.bind(this);
+ }
+
updateProjection(id) {
const { updateProjection, config, onCloseModal } = this.props;
updateProjection(id, config);
@@ -57,7 +62,7 @@ class ProjectionList extends Component {
<IconList
list={projectionArray}
active={projection}
- onClick={this.updateProjection.bind(this)}
+ onClick={this.updateProjection}
size="small"
/>
);
diff --git a/web/js/containers/share.js b/web/js/containers/share.js
index af941466f..07184c0dd 100644
--- a/web/js/containers/share.js
+++ b/web/js/containers/share.js
@@ -38,6 +38,8 @@ class ShareLinkContainer extends Component {
tooltipOpen: false,
queryString: history.location.search || '',
};
+ this.onToggleShorten = this.onToggleShorten.bind(this);
+ this.onLinkClick = this.onLinkClick.bind(this);
}
componentDidMount() {
@@ -199,13 +201,13 @@ class ShareLinkContainer extends Component {
<Checkbox
label="Shorten link"
id="wv-link-shorten"
- onCheck={this.onToggleShorten.bind(this)}
+ onCheck={this.onToggleShorten}
checked={isShort}
disabled={!shortLink.isLoading}
/>
<br />
</div>
- <ShareLinks onClick={this.onLinkClick.bind(this)} />
+ <ShareLinks onClick={this.onLinkClick} />
</>
);
}
diff --git a/web/js/containers/sidebar/sidebar.js b/web/js/containers/sidebar/sidebar.js
index 7cb58cfe2..b858fc04e 100644
--- a/web/js/containers/sidebar/sidebar.js
+++ b/web/js/containers/sidebar/sidebar.js
@@ -54,6 +54,7 @@ class Sidebar extends React.Component {
customPalettePromise.done((customs) => {
props.loadedCustomPalettes(customs);
});
+ this.toggleSidebar = this.toggleSidebar.bind(this);
}
componentDidMount() {
@@ -187,7 +188,7 @@ class Sidebar extends React.Component {
<CollapsedButton
isMobile={isMobile}
isCollapsed={isCollapsed}
- onclick={this.toggleSidebar.bind(this)}
+ onclick={this.toggleSidebar}
numberOfLayers={numberOfLayers}
/>
<div
@@ -210,7 +211,7 @@ class Sidebar extends React.Component {
onTabClick={onTabClick}
tabTypes={tabTypes}
isMobile={isMobile}
- toggleSidebar={this.toggleSidebar.bind(this)}
+ toggleSidebar={this.toggleSidebar}
isCompareMode={isCompareMode}
isDataDisabled={isDataDisabled}
/>
diff --git a/web/js/containers/tour.js b/web/js/containers/tour.js
index 18270f731..d359315f9 100644
--- a/web/js/containers/tour.js
+++ b/web/js/containers/tour.js
@@ -52,6 +52,9 @@ class Tour extends React.Component {
this.toggleModalComplete = this.toggleModalComplete.bind(this);
this.incrementStep = this.incrementStep.bind(this);
this.decreaseStep = this.decreaseStep.bind(this);
+ this.endTour = this.endTour.bind(this);
+ this.selectTour = this.selectTour.bind(this);
+ this.resetTour = this.resetTour.bind(this);
}
componentDidMount() {
@@ -330,7 +333,7 @@ class Tour extends React.Component {
toggleModalStart={this.toggleModalStart}
toggleModalInProgress={this.toggleModalInProgress}
toggleModalComplete={this.toggleModalComplete}
- selectTour={this.selectTour.bind(this)}
+ selectTour={this.selectTour}
showTourAlert={showTourAlert}
hideTour={() => {
hideTour();
@@ -340,13 +343,13 @@ class Tour extends React.Component {
showTour();
this.setState({ showDisabledAlert: false });
}}
- endTour={this.endTour.bind(this)}
+ endTour={this.endTour}
/>
) : modalInProgress ? (
<TourInProgress
config={config}
models={models}
- endTour={this.endTour.bind(this)}
+ endTour={this.endTour}
modalInProgress={modalInProgress}
toggleModalStart={this.toggleModalStart}
toggleModalInProgress={this.toggleModalInProgress}
@@ -371,8 +374,8 @@ class Tour extends React.Component {
toggleModalStart={this.toggleModalStart}
toggleModalInProgress={this.toggleModalInProgress}
toggleModalComplete={this.toggleModalComplete}
- resetTour={this.resetTour.bind(this)}
- endTour={this.endTour.bind(this)}
+ resetTour={this.resetTour}
+ endTour={this.endTour}
/>
)}
</div>