@@ -50,6 +50,8 @@ module.exports = React.createClass({
50
50
} ,
51
51
52
52
componentWillMount : function ( ) {
53
+ this . mounted = false ;
54
+
53
55
var cli = MatrixClientPeg . get ( ) ;
54
56
cli . on ( "Room" , this . onRoom ) ;
55
57
cli . on ( "deleteRoom" , this . onDeleteRoom ) ;
@@ -69,6 +71,8 @@ module.exports = React.createClass({
69
71
this . dispatcherRef = dis . register ( this . onAction ) ;
70
72
// Initialise the stickyHeaders when the component is created
71
73
this . _updateStickyHeaders ( true ) ;
74
+
75
+ this . mounted = true ;
72
76
} ,
73
77
74
78
componentDidUpdate : function ( ) {
@@ -106,6 +110,8 @@ module.exports = React.createClass({
106
110
} ,
107
111
108
112
componentWillUnmount : function ( ) {
113
+ this . mounted = false ;
114
+
109
115
dis . unregister ( this . dispatcherRef ) ;
110
116
if ( MatrixClientPeg . get ( ) ) {
111
117
MatrixClientPeg . get ( ) . removeListener ( "Room" , this . onRoom ) ;
@@ -311,6 +317,7 @@ module.exports = React.createClass({
311
317
} ,
312
318
313
319
_getScrollNode : function ( ) {
320
+ if ( ! this . mounted ) return null ;
314
321
var panel = ReactDOM . findDOMNode ( this ) ;
315
322
if ( ! panel ) return null ;
316
323
@@ -337,6 +344,7 @@ module.exports = React.createClass({
337
344
var incomingCallBox = document . getElementById ( "incomingCallBox" ) ;
338
345
if ( incomingCallBox && incomingCallBox . parentElement ) {
339
346
var scrollArea = this . _getScrollNode ( ) ;
347
+ if ( ! scrollArea ) return ;
340
348
// Use the offset of the top of the scroll area from the window
341
349
// as this is used to calculate the CSS fixed top position for the stickies
342
350
var scrollAreaOffset = scrollArea . getBoundingClientRect ( ) . top + window . pageYOffset ;
@@ -360,6 +368,7 @@ module.exports = React.createClass({
360
368
// properly through React
361
369
_initAndPositionStickyHeaders : function ( initialise , scrollToPosition ) {
362
370
var scrollArea = this . _getScrollNode ( ) ;
371
+ if ( ! scrollArea ) return ;
363
372
// Use the offset of the top of the scroll area from the window
364
373
// as this is used to calculate the CSS fixed top position for the stickies
365
374
var scrollAreaOffset = scrollArea . getBoundingClientRect ( ) . top + window . pageYOffset ;
0 commit comments