From 67372d4fed3caa946e8fa6abea93d166af86d359 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 11 Jul 2017 17:03:25 +0100 Subject: [PATCH] Give Login an unmounted guard --- src/components/structures/login/Login.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/structures/login/Login.js b/src/components/structures/login/Login.js index 27c0c200be..a081d2a205 100644 --- a/src/components/structures/login/Login.js +++ b/src/components/structures/login/Login.js @@ -72,9 +72,14 @@ module.exports = React.createClass({ }, componentWillMount: function() { + this._unmounted = false; this._initLoginLogic(); }, + componentWillUnmount: function() { + this._unmounted = true; + }, + onPasswordLogin: function(username, phoneCountry, phoneNumber, password) { this.setState({ busy: true, @@ -87,6 +92,9 @@ module.exports = React.createClass({ ).then((data) => { this.props.onLoggedIn(data); }, (error) => { + if(this._unmounted) { + return; + } let errorText; // Some error strings only apply for logging in @@ -109,8 +117,11 @@ module.exports = React.createClass({ loginIncorrect: error.httpStatus === 401 || error.httpStatus == 403, }); }).finally(() => { + if(this._unmounted) { + return; + } this.setState({ - busy: false + busy: false, }); }).done(); },