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

611 阅读1分钟

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

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 folder

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