You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-15 11:01:52 +03:00
Set our own booleans instead of using isMounted
This commit is contained in:
@ -100,6 +100,12 @@ module.exports = React.createClass({
|
||||
},
|
||||
|
||||
componentWillUnmount: function() {
|
||||
// set a boolean to say we've been unmounted, which any pending
|
||||
// promises can use to throw away their results.
|
||||
//
|
||||
// (We could use isMounted, but facebook have deprecated that.)
|
||||
this.unmounted = true;
|
||||
|
||||
if (this.refs.messagePanel) {
|
||||
// disconnect the D&D event listeners from the message panel. This
|
||||
// is really just for hygiene - the messagePanel is going to be
|
||||
@ -196,7 +202,7 @@ module.exports = React.createClass({
|
||||
},*/
|
||||
|
||||
onRoomTimeline: function(ev, room, toStartOfTimeline) {
|
||||
if (!this.isMounted()) return;
|
||||
if (this.unmounted) return;
|
||||
|
||||
// ignore anything that comes in whilst paginating: we get one
|
||||
// event for each new matrix event so this would cause a huge
|
||||
@ -355,7 +361,7 @@ module.exports = React.createClass({
|
||||
|
||||
// we might have switched rooms since the paginate started - just bin
|
||||
// the results if so.
|
||||
if (!this.isMounted()) return;
|
||||
if (this.unmounted) return;
|
||||
|
||||
this.setState({
|
||||
room: MatrixClientPeg.get().getRoom(this.props.roomId),
|
||||
@ -538,7 +544,7 @@ module.exports = React.createClass({
|
||||
|
||||
return searchPromise.then(function(results) {
|
||||
debuglog("search complete");
|
||||
if (!this.isMounted() || !self.state.searching || self.searchId != localSearchId) {
|
||||
if (self.unmounted || !self.state.searching || self.searchId != localSearchId) {
|
||||
console.error("Discarding stale search results");
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user