gpt4 book ai didi

android - 使用 react 抽屉导航在 iOS 上 react native 崩溃

转载 作者:可可西里 更新时间:2023-11-01 04:55:00 29 4
gpt4 key购买 nike

我只在 iOS 上遇到错误:

TypeError: undefined is not an object (evaluating 'this._callListeners.bind')

This error is located at:
in DrawerLayout (at DrawerView.js:161)
...

项目依赖:

"dependencies": {
"@babel/runtime": "7.2.0",
"@babel/plugin-proposal-async-generator-functions": "7.2.0",
"@babel/plugin-proposal-class-properties": "7.2.1",
"@babel/plugin-proposal-object-rest-spread": "7.2.0",
"babel-preset-expo": "5.0.0",
"expo": "31.0.2",
"expo-cli": "2.5.0",
"native-base": "2.8.1",
"react": "16.6.3",
"react-native": "0.57.8",
"react-redux": "6.0.0",
"react-navigation": "3.0.8",
"react-native-vector-icons": "6.1.0",
"redux": "4.0.1"
}

这是从我开始使用 react-navigation 开始的;但在 Android 上运行良好。

这是我们使用 react-navigation 的代码,这是导入的主要应用程序,包括主屏幕和设置屏幕:

//imports...

const routes = {
Home: Home,
Settings: Settings
};

const AppNavigator = createDrawerNavigator(routes);

const AppContainer = createAppContainer(AppNavigator);

export default class App extends React.Component {
state = {}

render() {
if (this.state.isReady) {
return (
<AppContainer/>
);
}
else {
return (<Container><Spinner/></Container>);
}
}

componentWillMount() {
this._loadAssets();
}

async _loadAssets() {
await Expo.Font.loadAsync({
Roboto: require("native-base/Fonts/Roboto.ttf"),
Roboto_medium: require("native-base/Fonts/Roboto_medium.ttf")
});

this.setState({ isReady: true });
}
}

最佳答案

我通过对我的 .babelrc

进行以下更改修复了同样的错误
{
"presets": ["module:metro-react-native-babel-preset"],
"plugins": [
- ["@babel/plugin-proposal-decorators", { "decoratorsBeforeExport": true }]
+ ["@babel/plugin-proposal-decorators", { "legacy": true }]
]
}

我的package.json:

"dependencies": {
"axios": "^0.18.0",
"mobx": "^5.8.0",
"mobx-react": "^5.4.3",
"react": "16.6.3",
"react-native": "0.57.8",
"react-native-device-info": "^0.24.3",
"react-native-elements": "^1.0.0-beta5",
"react-native-haptic-feedback": "^1.3.0",
"react-native-svg": "^8.0.10",
"react-native-vector-icons": "^6.0.2",
"react-navigation": "^3.0.9",
"rollbar-react-native": "^0.4.0"
},
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-decorators": "^7.2.3",
"babel-eslint": "^10.0.1",
"babel-jest": "23.6.0",
"eslint": "^5.12.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.12.3",
"eslint-plugin-react-native": "^3.5.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.51.1",
"react-test-renderer": "16.6.3"
}

关于android - 使用 react 抽屉导航在 iOS 上 react native 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53783166/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com