Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference
See original GitHub issueThis native code exception occured when I was extracting Gesture Handlers into a component.
Compare this:
function ThisWorks() {
return (
<TapGestureHandler>
<MyView/>
</TapGestureHandler>
)
}
to this:
function ThisCrashes() {
return (
<MyTapHandler>
<MyView/>
</MyTapHandler>
)
}
function MyTapHandler({children}) {
return (
<TapGestureHandler>
{children}
</TapGestureHandler>
)
}
This problem might be related to the fact that children is internally an array of components (even if the length is 1), it can be worked around by wrapping it into a <View>:
function MyTapHandlerFixed({children}) {
return (
<TapGestureHandler>
<View>{children}</View>
</TapGestureHandler>
)
}
Usually, when I add multiple children to a GestureHandler, I’m getting this error from the library: Invariant Violation: React.Children.only expected to receive a single React element child.
This error does not occur when the value is passed as the {children} prop as described above. Instead, a hard to debug native exception occured. Not sure if this is an error of react-native-gesture-handler or of react-native itself, but I wanted to post here to give a heads-up to other people who might encounter this.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:22
- Comments:8 (3 by maintainers)

Top Related StackOverflow Question
@peritus I’m having the same issue with
RefreshControlEDIT: This comment helped me: https://github.com/software-mansion/react-native-gesture-handler/issues/1067#issuecomment-724688373Hey, I have just tested it on
1.10.2and it seems to work, so could you update the version of the gesture handler and let me know if It works for you?In this thread, I can see another issue related to
RefreshControlbut this thread should be continued here: https://github.com/software-mansion/react-native-gesture-handler/issues/1067