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. Here is my code App.js `/**
- Sample React Native App
- https://github.com/facebook/react-native
- @format
- @flow
- @lint-ignore-every XPLATJSCOPYRIGHT1 */
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
- fix: jest tests to setup react-native-gesture-handler and ignore transforming react-native / react-navigation packages See https://github.com/kmagiera/react-native-gesture-handler/issues/497#issuecom... — committed to audiolion/react-native-spotify by audiolion 5 years ago
- feat: react navigation (#11) * build: react-navigation react-navigation-stack + deps * default styles for App's SafeAreaView * StubScreen component * feat: navigation setup We use a top lev... — committed to audiolion/react-native-spotify by audiolion 5 years ago
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.
For Cocoapods project, dont forget to install pods after linking:
For me this is happening only in tests:
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
@henninghall Sadly the issue persists even after pod install.
@pke Same problem with my setup. Its running fine but this test is getting failed.