我正在使用本机响应,现在尝试安装加载组件时出现以下错误。
TypeError:未定义不是对象(正在评估'this.props.navigation.navigate')]
这是我的代码
import React from 'react';
import SplashScreen from 'react-native-splash-screen';
import Loading from '../../components/loading/Loading';
import { connect } from 'react-redux';
class LoadingContainer extends React.Component {
componentDidMount() {
setTimeout(() => {
SplashScreen.hide();
}, 300);
let initRoute;
if (this.props.auth.user) {
initRoute = 'App';
} else {
initRoute = 'Login';
}
this.props.navigation.navigate(initRoute);
}
render() {
return <Loading navigation={this.props.navigation} />;
}
}
const mapStateToProps = state => ({
auth: state.auth,
});
export default connect(mapStateToProps, null)(LoadingContainer);
这是我第一次使用react-navigation时遇到此错误,我使用的是2.11.2版本的react-navigation。>
我正在使用本机响应,现在尝试安装加载组件时出现以下错误。 TypeError:未定义不是对象(正在评估'this.props.navigation.navigate'...
您为什么不使用react-navigation v4.x?