Bug 1451171 - Transition away from unsafe lifecycle functions

This commit is contained in:
Cameron Dawson 2018-10-23 08:51:46 -07:00
Родитель ed5126a252
Коммит ad7e0a7da4
4 изменённых файлов: 14 добавлений и 21 удалений

Просмотреть файл

@ -7,20 +7,13 @@ export default class JobButtonComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
isSelected: false,
isRunnableSelected: false,
};
}
componentWillMount() {
const { job } = this.props;
const { id } = job;
const urlSelectedJob = getUrlParam('selectedJob');
if (parseInt(urlSelectedJob) === id) {
this.setState({ isSelected: true });
}
this.state = {
isSelected: parseInt(urlSelectedJob) === job.id,
isRunnableSelected: false,
};
}
componentDidMount() {

Просмотреть файл

@ -68,11 +68,8 @@ class PushHeader extends React.PureComponent {
this.pushDateStr = toDateStr(pushTimestamp);
}
componentWillMount() {
this.triggerNewJobs = this.triggerNewJobs.bind(this);
}
componentDidMount() {
this.triggerNewJobs = this.triggerNewJobs.bind(this);
this.pinAllShownJobs = this.pinAllShownJobs.bind(this);
this.cancelAllJobs = this.cancelAllJobs.bind(this);
}

Просмотреть файл

@ -15,9 +15,7 @@ class LoginCallback extends React.PureComponent {
this.authService = new AuthService();
}
async componentWillMount() {
let authResult;
async componentDidMount() {
// make the user login if there is no access token
if (!window.location.hash) {
return webAuth.authorize();
@ -32,7 +30,7 @@ class LoginCallback extends React.PureComponent {
}
try {
authResult = await parseHash({ hash: window.location.hash });
const authResult = await parseHash({ hash: window.location.hash });
if (authResult.accessToken) {
await this.authService.saveCredentialsFromAuthResult(authResult);
@ -45,10 +43,14 @@ class LoginCallback extends React.PureComponent {
}
}
} catch (err) {
return this.setState({ loginError: err.message ? err.message : err.errorDescription });
this.setError(err);
}
}
setError(err) {
this.setState({ loginError: err.message ? err.message : err.errorDescription });
}
render() {
if (this.state.loginError) {
return <p>{this.state.loginError}</p>;

Просмотреть файл

@ -13,7 +13,8 @@ const mapStateToProps = ({ groups }) => groups;
class Groups extends React.Component {
componentWillMount() {
constructor(props) {
super(props);
this.filterStr = new URLSearchParams(location.search).get('filter') || '';
}