react-native-gesture-handler isn't working (null is not an object)

React Native 升级为0.60后,会出现null is not an object问题,如今的解决方案以下react

null is not an object

Step 1 -- Disable autolinking for iOS and Not for Android
  • module linked
react-native unlink react-native-gesture-handler --platform iOS
复制代码
  • module not linked
react-native link react-native-gesture-handler --platform android
复制代码
Step 2 -- Create file in root project react-native.config.js
module.exports = {
  dependencies: {
    'react-native-gesture-handler': {
      platforms: {
        ios: null, // disable ios platform, other platforms will still autolink
      },
    },
  },
};
复制代码
Step 3 -- Pod iOS and install jetify
For iOS

pod install on iOS folderandroid

cd ios
pod install
复制代码
For Android
  1. npm install -save-dev jetifier or yarn add -D jetifier
  2. add script in package.json file
"scripts": {
    ...
    "postinstall":"npx jetify"
  },
复制代码
  1. Run npm install or yarn;
Step 4 -- run your app as you like
相关文章
相关标签/搜索