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
相關文章
相關標籤/搜索