Skip to content

Commit 8ac26dd

Browse files
committed
Give HomePage an unmounted guard
Also add missing return in error-handling path
1 parent b375c71 commit 8ac26dd

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎src/components/structures/HomePage.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ module.exports = React.createClass({
5252
},
5353

5454
componentWillMount: function() {
55+
this._unmounted = false;
56+
5557
if (this.props.teamToken && this.props.teamServerUrl) {
5658
this.setState({
5759
iframeSrc: `${this.props.teamServerUrl}/static/${this.props.teamToken}/home.html`
@@ -67,9 +69,14 @@ module.exports = React.createClass({
6769
request(
6870
{ method: "GET", url: src },
6971
(err, response, body) => {
72+
if (this.unmounted) {
73+
return;
74+
}
75+
7076
if (err || response.status < 200 || response.status >= 300) {
7177
console.log(err);
7278
this.setState({ page: "Couldn't load home page" });
79+
return;
7380
}
7481

7582
body = body.replace(/_t\(['"]([\s\S]*?)['"]\)/mg, (match, g1)=>this.translate(g1));
@@ -79,6 +86,10 @@ module.exports = React.createClass({
7986
}
8087
},
8188

89+
componentWillUnmount: function() {
90+
this._unmounted = true;
91+
},
92+
8293
render: function() {
8394
if (this.state.iframeSrc) {
8495
return (

0 commit comments

Comments
 (0)