react-native-gesture-handler: Cannot read property 'Direction' of undefined

Hello, I have just installed Pods so I can incorporate blinkid. I only started reciving this issue when I linked react-native-gesture to a podfile. screen shot 2019-03-04 at 4 45 29 pm Here is my code App.js `/**

import React, {Component} from ‘react’; import {Platform, StyleSheet, Text, View} from ‘react-native’; // import store from ‘./app/store/store’ import { Provider } from ‘mobx-react’; // import {UserStore} from ‘./app/store/UserStore’ import {RootStore} from ‘./app/store/RootStore’ import NavigationService from ‘./app/navigation/NavigationService’ // const store = configuireStore({}) import RootNavigator from ‘./app/navigation/RootNavigator’ const instructions = Platform.select({ ios: ‘Press Cmd+R to reload,\n’ + ‘Cmd+D or shake for dev menu’, android: ‘Double tap R on your keyboard to reload,\n’ + ‘Shake or press menu button for dev menu’, });

type Props = {}; export default class App extends Component<Props> { render() { this.store = RootStore.create({}) return ( <Provider store={this.store}> <RootNavigator ref={navigatorRef => { NavigationService.setTopLevelNavigator(navigatorRef)}}/> </Provider> ); } }

const styles = StyleSheet.create({ container: { flex: 1, justifyContent: ‘center’, alignItems: ‘center’, backgroundColor: ‘#F5FCFF’, }, welcome: { fontSize: 20, textAlign: ‘center’, margin: 10, }, instructions: { textAlign: ‘center’, color: ‘#333333’, marginBottom: 5, }, });` RootNavigator

`import { createAppContainer, createStackNavigator } from ‘react-navigation’ import PreNavigator from ‘./PreNavigator.js’ import MainNavigator from ‘./MainNavigator’ const RootStack = createStackNavigator({ Pre: { screen: PreNavigator }, Main: { screen: MainNavigator } }, { initialRouteName: ‘Main’, headerMode: ‘none’, navigationOptions: { headerVisible: false, gesturesEnabled: true } })

export default createAppContainer(RootStack)`

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (1 by maintainers)

Commits related to this issue

Most upvoted comments

It is not necessary to create a setup file as @etcaples references in her comment. The jest setup is hidden in the documentation as @andreialecu writes in issue #344

Add to “jest” in package.json: setupFiles: [ "./node_modules/react-native-gesture-handler/jestSetup.js" ]

Solved my own problem.

  1. Right Click Libraries “Add Files to Project”
  2. /node_modules/react-native-gesture-handlers/ios/RNGestureHandler.xcodeproj
  3. Go to build phases and add libRNGestureHandler.a
  4. Run

For Cocoapods project, dont forget to install pods after linking:

cd ios
pod install

For me this is happening only in tests:

import "react-native"
import React from "react"
import App from "./App"

// Note: test renderer must be required after react-native.
import renderer from "react-test-renderer"

it("renders correctly", () => {
  renderer.create(<App />)
})

App is using @react-navigation/native which depends on gesture handler. In my index.js its the firt import and the app runs fine, just this one test fails.

What about solving the same error for android??

I was able to fix my same issue of 'Direction' undefined with @matheushf comment in Issue #344. On my end, looks like our jest setup file hadn’t included a config for gesture handling.

Edit: fixed broken url link

Not working on Android still the same errorl, integrated react-native-gesture-handler when using react-native-tab-view

For Cocoapods project, dont forget to install pods after linking:

cd ios
pod install

@henninghall Sadly the issue persists even after pod install.

@pke Same problem with my setup. Its running fine but this test is getting failed.