File tree Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ export default class ObserveBoundingClientRect extends React.PureComponent<
3636 IProps ,
3737 IState
3838> {
39- private tickId : number ;
39+ private tickId ? : number ;
4040
4141 constructor ( props : IProps ) {
4242 super ( props ) ;
@@ -76,7 +76,9 @@ export default class ObserveBoundingClientRect extends React.PureComponent<
7676 }
7777
7878 componentWillUnmount ( ) {
79- cancelAnimationFrame ( this . tickId ) ;
79+ if ( typeof this . tickId === 'number' ) {
80+ cancelAnimationFrame ( this . tickId ) ;
81+ }
8082 }
8183
8284 tick ( updater : Function ) {
Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ export default class ViewportCollector extends React.PureComponent<IProps> {
149149 private dimensionsState : IDimensions ;
150150 private lastSyncedScrollState : IScroll ;
151151 private lastSyncedDimensionsState : IDimensions ;
152- private tickId : NodeJS . Timeout ;
152+ private tickId ?: number ;
153153 private componentMightHaveUpdated : boolean ;
154154 private resizeObserver : ResizeObserver | null ;
155155
@@ -158,7 +158,7 @@ export default class ViewportCollector extends React.PureComponent<IProps> {
158158 this . state = {
159159 parentProviderExists : false ,
160160 } ;
161-
161+ this . componentMightHaveUpdated = false ;
162162 this . scrollState = createEmptyScrollState ( ) ;
163163 this . dimensionsState = createEmptyDimensionState ( ) ;
164164 this . lastSyncedDimensionsState = { ...this . dimensionsState } ;
@@ -202,7 +202,9 @@ export default class ViewportCollector extends React.PureComponent<IProps> {
202202 this . resizeObserver . disconnect ( ) ;
203203 this . resizeObserver = null ;
204204 }
205- cancelAnimationFrame ( this . tickId ) ;
205+ if ( typeof this . tickId === 'number' ) {
206+ cancelAnimationFrame ( this . tickId ) ;
207+ }
206208 }
207209
208210 tick = ( ) => {
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ export default class ViewportProvider extends React.PureComponent<
8383 experimentalSchedulerEnabled : false ;
8484 } ;
8585 private listeners : IListener [ ] = [ ] ;
86- private updateListenersTick : NodeJS . Timer ;
86+ private updateListenersTick ? : NodeJS . Timer ;
8787
8888 constructor ( props : IProps ) {
8989 super ( props ) ;
@@ -93,7 +93,9 @@ export default class ViewportProvider extends React.PureComponent<
9393 }
9494
9595 componentWillUnmount ( ) {
96- clearTimeout ( this . updateListenersTick ) ;
96+ if ( typeof this . updateListenersTick === 'number' ) {
97+ clearTimeout ( this . updateListenersTick ) ;
98+ }
9799 }
98100
99101 triggerUpdateToListeners = (
@@ -172,7 +174,9 @@ export default class ViewportProvider extends React.PureComponent<
172174 } ;
173175
174176 updateHasListenersState ( ) {
175- clearTimeout ( this . updateListenersTick ) ;
177+ if ( typeof this . updateListenersTick === 'number' ) {
178+ clearTimeout ( this . updateListenersTick ) ;
179+ }
176180 this . updateListenersTick = setTimeout ( ( ) => {
177181 this . setState ( {
178182 hasListeners : this . listeners . length !== 0 ,
You can’t perform that action at this time.
0 commit comments