@@ -360,13 +360,9 @@ export default abstract class GestureHandler implements IGestureHandler {
360
360
if ( ! this . enabled ) {
361
361
return ;
362
362
}
363
- if ( ! this . propsRef ) {
364
- throw new Error (
365
- tagMessage ( 'Cannot handle event when component props are null' )
366
- ) ;
367
- }
363
+ this . ensurePropsRef ( ) ;
368
364
const { onGestureHandlerEvent, onGestureHandlerTouchEvent } : PropsRef =
369
- this . propsRef . current ;
365
+ this . propsRef ! . current ;
370
366
371
367
const touchEvent : ResultTouchEvent | undefined =
372
368
this . transformTouchEvent ( event ) ;
@@ -388,16 +384,12 @@ export default abstract class GestureHandler implements IGestureHandler {
388
384
//
389
385
390
386
public sendEvent = ( newState : State , oldState : State ) : void => {
391
- if ( ! this . propsRef ) {
392
- throw new Error (
393
- tagMessage ( 'Cannot handle event when component props are null' )
394
- ) ;
395
- }
387
+ this . ensurePropsRef ( ) ;
396
388
const {
397
389
onGestureHandlerEvent,
398
390
onGestureHandlerStateChange,
399
391
onGestureHandlerAnimatedEvent,
400
- } : PropsRef = this . propsRef . current ;
392
+ } : PropsRef = this . propsRef ! . current ;
401
393
const resultEvent : ResultEvent = this . transformEventData (
402
394
newState ,
403
395
oldState
@@ -545,11 +537,7 @@ export default abstract class GestureHandler implements IGestureHandler {
545
537
}
546
538
547
539
private cancelTouches ( ) : void {
548
- if ( ! this . propsRef ) {
549
- throw new Error (
550
- tagMessage ( 'Cannot handle event when component props are null' )
551
- ) ;
552
- }
540
+ this . ensurePropsRef ( ) ;
553
541
const rect = this . delegate . measureView ( ) ;
554
542
555
543
const all : PointerData [ ] = [ ] ;
@@ -594,11 +582,19 @@ export default abstract class GestureHandler implements IGestureHandler {
594
582
timeStamp : Date . now ( ) ,
595
583
} ;
596
584
597
- const { onGestureHandlerEvent } : PropsRef = this . propsRef . current ;
585
+ const { onGestureHandlerEvent } : PropsRef = this . propsRef ! . current ;
598
586
599
587
invokeNullableMethod ( onGestureHandlerEvent , cancelEvent ) ;
600
588
}
601
589
590
+ protected ensurePropsRef ( ) : void {
591
+ if ( ! this . propsRef ) {
592
+ throw new Error (
593
+ tagMessage ( 'Cannot handle event when component props are null' )
594
+ ) ;
595
+ }
596
+ }
597
+
602
598
protected transformNativeEvent ( ) : Record < string , unknown > {
603
599
// Those properties are shared by most handlers and if not this method will be overriden
604
600
const lastCoords = this . tracker . getAbsoluteCoordsAverage ( ) ;
0 commit comments