TypeError: null is not an object (evaluating 'RNGestureHandlerModule.default.Direction')

我只是一个虾纸丫 提交于 2020-04-18 04:03:10

问题


I have problem with module 'react-navigation-stack' I've written the same code from https://facebook.github.io/react-native/docs/navigation#react-navigation. Platform: Android. OS: ubuntu

import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';
import SearchScreen from './scr/screen/SearchScreen';

const navigator = createStackNavigator(
    {
        Search: SearchScreen
    },
    {
        initialRouteName: 'Search',
        defaultNavigationOptions: {
            title: 'App'
        }
    }
);
const App = createAppContainer(navigator);
export default App;


回答1:


Try to add curly braces around createStackNavigator like so:

{ createStackNavigator }




回答2:


this is the fixed app. https://snack.expo.io/@whitedragon226/stackdemo

Fixed lines

import React from 'react';

and add some dependencies

...
    "react-native-screens": "^1.0.0-alpha",
    "react-native-gesture-handler": "^1.0.0"

this doc is may help you.




回答3:


I think it's bug or I don't know. After all of action from https://reactnavigation.org/docs/en/getting-started.html You need reinstall application in your device. I hope it's work for you.




回答4:


How I have solved the RNGestureHandlerModule.default.Direction error:

  1. be sure that you put that import at the top of your entry point script file

    import 'react-native-gesture-handler';
    
  2. clean Gradle

    cd ./android && ./gradlew clean && cd ..
    
  3. start the Android app with

    react-native run-android --verbose
    

and be sure this you see that line in bundler logs:

> Task :react-native-gesture-handler:compileDebugJavaWithJavac

if you do not see it it looks like bundle did not link react-native-gesture-handler to your app.

Especially check 1) if you have a monorepo with a mobile version index.js|tsx in one package and the whole app in another - import should be added at the top of the mobile entry point script.



来源:https://stackoverflow.com/questions/58955199/typeerror-null-is-not-an-object-evaluating-rngesturehandlermodule-default-dir

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!