From 54365d3566874bc8c8c97a865ad264624a150491 Mon Sep 17 00:00:00 2001 From: John Lyon-Smith Date: Fri, 23 Mar 2018 07:33:52 -0700 Subject: [PATCH] Add some more autobinds --- website/src/Auth/ConfirmEmail.js | 3 ++- website/src/Auth/ProtectedRoute.js | 7 ++----- website/src/Profile/ProfileForm.js | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/website/src/Auth/ConfirmEmail.js b/website/src/Auth/ConfirmEmail.js index 0babc50..0182b67 100644 --- a/website/src/Auth/ConfirmEmail.js +++ b/website/src/Auth/ConfirmEmail.js @@ -2,6 +2,7 @@ import React from 'react' import { api } from 'src/API' import PropTypes from 'prop-types' import { MessageModal, WaitModal } from '../Modal' +import autobind from 'autobind-decorator' export class ConfirmEmail extends React.Component { static propTypes = { @@ -13,7 +14,6 @@ export class ConfirmEmail extends React.Component { waitModal: null, messageModal: null } - this.handleMessageModalDismiss = this.handleMessageModalDismiss.bind(this) } componentDidMount(props) { @@ -47,6 +47,7 @@ export class ConfirmEmail extends React.Component { } } + @autobind handleMessageModalDismiss() { this.setState({ messageModal: null }) this.props.history.replace('/login') diff --git a/website/src/Auth/ProtectedRoute.js b/website/src/Auth/ProtectedRoute.js index 0b531b3..663de1d 100644 --- a/website/src/Auth/ProtectedRoute.js +++ b/website/src/Auth/ProtectedRoute.js @@ -2,6 +2,7 @@ import React from 'react' import { Route, Redirect } from 'react-router-dom' import { PropTypes } from 'prop-types' import { api } from 'src/API' +import autobind from 'autobind-decorator' export class ProtectedRoute extends React.Component { static propTypes = { @@ -15,11 +16,7 @@ export class ProtectedRoute extends React.Component { roles: ['administrator'] } - constructor(props) { - super(props) - this.updateComponent = this.updateComponent.bind(this) - } - + @autobind updateComponent() { this.forceUpdate() } diff --git a/website/src/Profile/ProfileForm.js b/website/src/Profile/ProfileForm.js index d462950..8b39616 100644 --- a/website/src/Profile/ProfileForm.js +++ b/website/src/Profile/ProfileForm.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types' import { Column, Button, BoundInput, BoundButton } from 'ui' import { regExpPattern } from 'regexp-pattern' import { FormBinder } from 'react-form-binder' +import autobind from 'autobind-decorator' export class ProfileForm extends React.Component { static propTypes = { @@ -62,8 +63,6 @@ export class ProfileForm extends React.Component { constructor(props) { super(props) - - this.handleSubmit = this.handleSubmit.bind(this) this.state = { binder: new FormBinder( this.props.user, ProfileForm.bindings, this.props.onModifiedChanged) @@ -79,6 +78,7 @@ export class ProfileForm extends React.Component { } } + @autobind handleSubmit(e) { e.preventDefault()