【发布时间】:2019-06-06 05:49:40
【问题描述】:
我正在尝试在 react native 项目 (android) 中使用 redux、thunk 和导航库来实现登录逻辑,但我得到了未处理的承诺拒绝 (id:0): (evalualting '_this.props.navigation') 知道是什么导致了这个问题或出路吗?
class AuthLoadingScreen extends React.Component {
constructor() {
super();
this._bootstrapAsync();
}
_bootstrapAsync = async () => {
this.props.getUserToken().then(() => {
this.props.navigation.navigate(this.props.token.token !== null ? Devices' : 'UserAuth');
}).catch(err => {
this.setState({ err })
})
};
render() {
return (
<View>
<ActivityIndicator />
<StatusBar barStyle="default" />
</View>
);
}
}
// actionCreator.js
export const getUserToken = () => dispatch =>
AsyncStorage.getItem('userToken')
.then((data) => {
dispatch(loading(false));
dispatch(getToken(data));
})
.catch((err) => {
dispatch(loading(false));
dispatch(error(err.message || 'ERROR'));
})
【问题讨论】:
标签: react-native react-redux react-native-navigation dispatch-async