Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give HomePage an unmounted guard #4556

Merged
merged 2 commits into from Jul 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/components/structures/HomePage.js
Expand Up @@ -52,6 +52,8 @@ module.exports = React.createClass({
},

componentWillMount: function() {
this._unmounted = false;

if (this.props.teamToken && this.props.teamServerUrl) {
this.setState({
iframeSrc: `${this.props.teamServerUrl}/static/${this.props.teamToken}/home.html`
Expand All @@ -67,9 +69,14 @@ module.exports = React.createClass({
request(
{ method: "GET", url: src },
(err, response, body) => {
if (this._unmounted) {
return;
}

if (err || response.status < 200 || response.status >= 300) {
console.log(err);
this.setState({ page: "Couldn't load home page" });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should _t this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably, but that sounds like a separate problem

return;
}

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

componentWillUnmount: function() {
this._unmounted = true;
},

render: function() {
if (this.state.iframeSrc) {
return (
Expand Down