Replace all uses of bind() with arrow functions

This commit is contained in:
Alex Liebowitz 2017-04-29 21:56:55 -04:00
parent 2bd12a9ecd
commit 0ffb0fd4d7
9 changed files with 22 additions and 22 deletions

View file

@ -145,9 +145,9 @@ var App = React.createClass({
this._isMounted = false;
},
registerHistoryPop: function() {
window.addEventListener("popstate", function() {
window.addEventListener("popstate", () => {
this.setState(this.getViewingPageAndArgs(location.pathname));
}.bind(this));
});
},
handleUpgradeClicked: function() {
// Make a new directory within temp directory so the filename is guaranteed to be available

View file

@ -78,12 +78,12 @@ const ConfirmEmailStage = React.createClass({
submitting: true,
});
const onSubmitError = function(error) {
const onSubmitError = (error) => {
if (this._codeRow) {
this._codeRow.showError(error.message)
}
this.setState({ submitting: false });
}.bind(this)
};
lbryio.call('user_email', 'confirm', {verification_token: this.state.code, email: this.props.email}, 'post').then((userEmail) => {
if (userEmail.IsVerified) {

View file

@ -34,11 +34,11 @@ var Drawer = React.createClass({
};
},
componentDidMount: function() {
this._balanceSubscribeId = lbry.balanceSubscribe(function(balance) {
this._balanceSubscribeId = lbry.balanceSubscribe((balance) => {
this.setState({
balance: balance
});
}.bind(this));
});
},
componentWillUnmount: function() {
if (this._balanceSubscribeId) {

View file

@ -10,9 +10,9 @@ var Header = React.createClass({
};
},
componentWillMount: function() {
new MutationObserver(function(mutations) {
new MutationObserver((mutations) => {
this.setState({ title: mutations[0].target.textContent });
}.bind(this)).observe(
}).observe(
document.querySelector('title'),
{ subtree: true, characterData: true, childList: true }
);

View file

@ -70,11 +70,11 @@ export let RewardLink = React.createClass({
return;
case 'first_publish':
lbry.claim_list_mine().then(function(list) {
lbry.claim_list_mine().then((list) => {
this.setState({
claimable: list.length > 0
})
}.bind(this));
});
return;
}
},

View file

@ -36,12 +36,12 @@ export const SnackBar = React.createClass({
let snack = this.state.snacks[0];
if (this._hideTimeout === null) {
this._hideTimeout = setTimeout(function() {
this._hideTimeout = setTimeout(() => {
this._hideTimeout = null;
let snacks = this.state.snacks;
snacks.shift();
this.setState({ snacks: snacks });
}.bind(this), this._displayTime * 1000);
}, this._displayTime * 1000);
}
return (

View file

@ -110,11 +110,11 @@ var FeaturedContent = React.createClass({
<div className="empty">Failed to load landing content.</div> :
<div>
{
Object.keys(this.state.featuredUris).map(function(category) {
Object.keys(this.state.featuredUris).map((category) => {
return this.state.featuredUris[category].length ?
<FeaturedCategory key={category} category={category} names={this.state.featuredUris[category]} /> :
'';
}.bind(this))
})
}
</div>
);

View file

@ -60,13 +60,13 @@ var SettingsPage = React.createClass({
document.title = "Settings";
},
componentWillMount: function() {
lbry.getDaemonSettings(function(settings) {
lbry.getDaemonSettings((settings) => {
this.setState({
daemonSettings: settings,
isMaxUpload: settings.max_upload != 0,
isMaxDownload: settings.max_download != 0
});
}.bind(this));
});
},
onShowNsfwChange: function(event) {
lbry.setClientSetting('showNsfw', event.target.checked);
@ -113,13 +113,13 @@ var SettingsPage = React.createClass({
<div className="form-row__label-row"><div className="form-field__label">Max Upload</div></div>
<FormRow type="radio"
name="max_upload_pref"
onChange={this.onMaxUploadPrefChange.bind(this, false)}
onChange={() => { this.onMaxUploadPrefChange(false) }}
defaultChecked={!this.state.isMaxUpload}
label="Unlimited" />
<div className="form-row">
<FormField type="radio"
name="max_upload_pref"
onChange={this.onMaxUploadPrefChange.bind(this, true)}
onChange={() => { this.onMaxUploadPrefChange(true) }}
defaultChecked={this.state.isMaxUpload}
label={ this.state.isMaxUpload ? 'Up to' : 'Choose limit...' } />
{ this.state.isMaxUpload ?
@ -142,12 +142,12 @@ var SettingsPage = React.createClass({
<FormRow label="Unlimited"
type="radio"
name="max_download_pref"
onChange={this.onMaxDownloadPrefChange.bind(this, false)}
onChange={() => { this.onMaxDownloadPrefChange(false) }}
defaultChecked={!this.state.isMaxDownload} />
<div className="form-row">
<FormField type="radio"
name="max_download_pref"
onChange={this.onMaxDownloadPrefChange.bind(this, true)}
onChange={() => { this.onMaxDownloadPrefChange(true) }}
defaultChecked={this.state.isMaxDownload}
label={ this.state.isMaxDownload ? 'Up to' : 'Choose limit...' } />
{ this.state.isMaxDownload ?

View file

@ -16,7 +16,7 @@ var AddressSection = React.createClass({
this.setState({
address: address,
});
}.bind(this));
});
},
_getNewAddress: function(event) {
@ -29,7 +29,7 @@ var AddressSection = React.createClass({
this.setState({
address: address,
});
}.bind(this));
});
},
getInitialState: function() {