【发布时间】:2018-12-14 16:04:27
【问题描述】:
我只在 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 的代码,这是导入的主应用程序,包括 Home 和 Settings 屏幕:
//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 });
}
}
【问题讨论】:
-
使用版本 2。版本 3 仍然有问题。
-
以前有用吗?这是一个新项目还是您更新了依赖项?
-
您似乎没有安装
react-native-gesture-handler,您是否遵循本指南:reactnavigation.org/blog/2018/11/17/react-navigation-3.0.html -
@RobbieMilejczak 它正在使用 Expo - 根据这些说明,不需要 react-native-gesture-handler。
-
@HelmerBarcos 在添加 react-navigation 之前它在 iOS 上工作。
标签: android ios react-native react-navigation