React-native-gesture-handler: [v 1.6.0] Unsupported top level event type "onGestureHandlerStateChange" dispatched

Created on 24 Apr 2020  路  1Comment  路  Source: software-mansion/react-native-gesture-handler

On some phones, we encounter this error.
Current versions:
react-native-gesture-handler: 1.6.0
Expo client: 2.15.4
RN: sdk 37

There is a closed issue with the problem. People are recommending to
import 'react-native-gesture-handler' in App.js
Unfortunately, it does not help.

There are some related closed issues where people still report this error
https://github.com/software-mansion/react-native-gesture-handler/issues/320
https://github.com/software-mansion/react-native-gesture-handler/issues/439

Most helpful comment

This works for me
https://github.com/software-mansion/react-native-gesture-handler/issues/320#issuecomment-463341145

just a bit refactored:

import { NativeModules } from 'react-native'

const { UIManager } = NativeModules

if (UIManager) {
  UIManager.genericDirectEventTypes = {
    ...UIManager.genericDirectEventTypes,
    onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },
    onGestureHandlerStateChange: {
      registrationName: 'onGestureHandlerStateChange',
    },
  }
}
...
import React, { Component } from 'react'

>All comments

This works for me
https://github.com/software-mansion/react-native-gesture-handler/issues/320#issuecomment-463341145

just a bit refactored:

import { NativeModules } from 'react-native'

const { UIManager } = NativeModules

if (UIManager) {
  UIManager.genericDirectEventTypes = {
    ...UIManager.genericDirectEventTypes,
    onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },
    onGestureHandlerStateChange: {
      registrationName: 'onGestureHandlerStateChange',
    },
  }
}
...
import React, { Component } from 'react'
Was this page helpful?
0 / 5 - 0 ratings