[英]TypeError: undefined is not an object (evaluating 'results.length') in Search Component
[英]TypeError: undefined is not an object (evaluating 'this._callListeners.bind')
我有一個不使用 Expo 的帶有打字稿的react-native應用程序。 在 iOS 中運行時,在啟動畫面后出現以下錯誤。 我知道這可能與react-navigation
使用react-native-gesture-handler
的事實有關,但這也包含在我的應用程序中並鏈接到了它。 也可能是因為缺少 typescript 類型,但添加@types/react-navigation
也無濟於事。
[error][tid:com.facebook.react.JavaScript] TypeError: undefined is not an object (evaluating 'this._callListeners.bind')
This error is located at:
in StackViewLayout (at withOrientation.js:30)
in withOrientation (at StackView.js:79)
in RCTView (at View.js:45)
in View (at Transitioner.js:215)
in Transitioner (at StackView.js:22)
in StackView (created by Navigator)
in Navigator (at createKeyboardAwareNavigator.js:12)
in KeyboardAwareNavigator (at createAppContainer.js:388)
in NavigationContainer (at App.tsx:69)
in Provider (at App.tsx:68)
in App (at renderApplication.js:34)
in RCTView (at View.js:45)
in View (at AppContainer.js:98)
in RCTView (at View.js:45)
in View (at AppContainer.js:115)
in AppContainer (at renderApplication.js:33)
我嘗試過 react-native 鏈接,清理 react native 緩存,刪除 node_modules 文件夾並重新安裝,清理 npm 緩存,從頭開始重新安裝應用程序,重置 iOS 模擬器內容。
以下是我的 package.json 供參考:
"dependencies": {
"autobind-decorator": "^2.4.0",
"axios": "^0.18.0",
"base64-js": "^1.3.0",
"bluebird": "^3.5.3",
"crypto-js": "^3.1.9-1",
"firebase": "^5.8.2",
"firebase-nest": "^0.7.1",
"i18next": "^12.1.0",
"jsc-android": "^236355.1.1",
"lodash": "^4.17.11",
"mobx": "^5.6.0",
"mobx-firebase-store": "^1.2.1",
"mobx-react": "^5.3.6",
"moment": "^2.22.2",
"native-base": "^2.11.0",
"react": "16.6.3",
"react-native": "^0.58.5",
"react-native-gesture-handler": "^1.0.15",
"react-native-splash-screen": "^3.2.0",
"react-native-swift": "^1.2.2",
"react-native-swiper": "^1.5.13",
"react-native-track-player": "^1.1.2",
"react-native-vector-icons": "^6.3.0",
"react-navigation": "^3.0.9",
"@types/bluebird": "^3.5.24",
"@types/react": "^16.8.3",
"@types/react-native": "^0.57.36",
"@types/react-navigation": "^3.0.3",
"@types/react-test-renderer": "^16.0.3"
},
"devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.3.3",
"@babel/plugin-proposal-decorators": "^7.1.6",
"@babel/preset-typescript": "^7.3.3",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "24.1.0",
"babel-preset-mobx": "^2.0.0",
"jest": "24.1.0",
"metro-react-native-babel-preset": "0.51.1",
"react-native-typescript-transformer": "^1.2.11",
"react-test-renderer": "16.6.3",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.16.0",
"tslint-config-standard": "^8.0.1",
"tslint-react": "^3.6.0",
"typescript": "^3.3.3"
},
還有我的 babelrc 內容:
{
"presets": [
"module:metro-react-native-babel-preset",
"mobx"
],
"plugins": [
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
],
[
"@babel/plugin-proposal-class-properties",
{
"loose": true
}
]
]
}
那些沒有解決這個問題的人。 嘗試在react-native run-android或ios之前在終端中運行react-native start。 就我而言,這完全是關於節點js窗口的
嘗試將@babel/plugin-transform-flow-strip-types
到babel.config.js
:
{
"presets": [
"module:metro-react-native-babel-preset",
"mobx"
],
"plugins": [
['@babel/plugin-transform-flow-strip-types'],
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
],
[
"@babel/plugin-proposal-class-properties",
{
"loose": true
}
]
]
}
參見https://github.com/react-navigation/react-navigation/issues/5825和https://github.com/babel/babel/issues/8417
好的,經過16小時的嘗試和錯誤,我設法找到了問題。 這是反應導航中的錯誤。 降級為"react-navigation": "^2.13.0"
解決了該問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.