From 7bf05b071533a9cf407637f00daa71bd9508c2fa Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 10 Feb 2018 16:01:19 +0000 Subject: [PATCH] add unmounted guard Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/elements/Reply.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/components/views/elements/Reply.js b/src/components/views/elements/Reply.js index c513535e85..31e94e1d4a 100644 --- a/src/components/views/elements/Reply.js +++ b/src/components/views/elements/Reply.js @@ -51,6 +51,8 @@ export default class Reply extends React.Component { }; this.onQuoteClick = this.onQuoteClick.bind(this); + + this.unmounted = false; } componentWillMount() { @@ -58,11 +60,17 @@ export default class Reply extends React.Component { this.initialize(); } + componentWillUnmount() { + this.unmounted = true; + } + async initialize() { const {parentEv} = this.props; const inReplyTo = Reply.getInReplyTo(parentEv); const ev = await this.getEvent(this.room, inReplyTo['event_id']); + if (this.unmounted) return; + if (ev) { this.setState({ events: [ev], @@ -78,6 +86,7 @@ export default class Reply extends React.Component { const inReplyTo = Reply.getInReplyTo(ev); if (!inReplyTo) { + if (this.unmounted) return; this.setState({ loading: false, }); @@ -85,6 +94,8 @@ export default class Reply extends React.Component { } const loadedEv = await this.getEvent(this.room, inReplyTo['event_id']); + if (this.unmounted) return; + if (loadedEv) { this.setState({loadedEv}); } else {