@@ -9,6 +9,13 @@ import NodeManager from './web/tools/NodeManager';
9
9
import * as HammerNodeManager from './web_hammer/NodeManager' ;
10
10
import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate' ;
11
11
12
+ // init method is called inside attachGestureHandler function. However, this function may
13
+ // fail when received view is not valid HTML element. On the other hand, dropGestureHandler
14
+ // will be called even if attach failed, which will result in crash.
15
+ //
16
+ // We use this flag to check whether or not dropGestureHandler should be called.
17
+ let shouldPreventDrop = false ;
18
+
12
19
export default {
13
20
handleSetJSResponder ( tag : number , blockNativeResponder : boolean ) {
14
21
console . warn ( 'handleSetJSResponder: ' , tag , blockNativeResponder ) ;
@@ -60,10 +67,18 @@ export default {
60
67
_actionType : ActionType ,
61
68
propsRef : React . RefObject < unknown >
62
69
) {
63
- if (
64
- ! ( newView instanceof HTMLElement || newView instanceof React . Component )
65
- ) {
66
- return ;
70
+ if ( ! ( newView instanceof Element || newView instanceof React . Component ) ) {
71
+ shouldPreventDrop = true ;
72
+
73
+ const handler = isNewWebImplementationEnabled ( )
74
+ ? NodeManager . getHandler ( handlerTag )
75
+ : HammerNodeManager . getHandler ( handlerTag ) ;
76
+
77
+ const handlerName = handler . constructor . name ;
78
+
79
+ throw new Error (
80
+ `${ handlerName } with tag ${ handlerTag } received child that is not valid HTML element.`
81
+ ) ;
67
82
}
68
83
69
84
if ( isNewWebImplementationEnabled ( ) ) {
@@ -94,6 +109,10 @@ export default {
94
109
}
95
110
} ,
96
111
dropGestureHandler ( handlerTag : number ) {
112
+ if ( shouldPreventDrop ) {
113
+ return ;
114
+ }
115
+
97
116
if ( isNewWebImplementationEnabled ( ) ) {
98
117
NodeManager . dropGestureHandler ( handlerTag ) ;
99
118
} else {
0 commit comments