action.js
export function getLoginStatus() {
return async(dispatch) => {
let token = await getOAuthToken();
let success = await verifyToken(token);
if (success == true) {
dispatch(loginStatus(success));
} else {
console.log("Success: False");
console.log("Token mismatch");
}
return success;
}
}
Run Code Online (Sandbox Code Playgroud)
component.js
componentDidMount() {
this.props.dispatch(splashAction.getLoginStatus())
.then((success) => {
if (success == true) {
Actions.counter()
} else {
console.log("Login not successfull");
}
});
}
Run Code Online (Sandbox Code Playgroud)
但是,当我用async/await编写component.js代码时,我得到此错误:
Possible Unhandled Promise Rejection (id: 0): undefined is not a function (evaluating 'this.props.dispatch(splashAction.getLoginStatus())')
component.js
async componentDidMount() {
let success = …Run Code Online (Sandbox Code Playgroud) reactjs react-native redux-thunk react-redux ecmascript-2017
我想每天午夜运行这个功能来检查expiry_date_notification.我能做什么?我是django和python的新手.
def check_expiry_date(request):
products = Product.objects.all()
for product in products:
product_id = product.id
expiry_date = product.expiry_date
notification_days = product.notification_days
check_date = int((expiry_date - datetime.datetime.today()).days)
if notification_days <= check_date:
notification = Notification(product_id=product_id)
notification.save()
Run Code Online (Sandbox Code Playgroud) 我打算用Django Rest Framework构建一个应用程序.我对使用Django-Rest-Framework-JWT认证机制比使用Session或Token认证机制更感兴趣.
但是所有其他软件包,如Django-Rest-Auth和Djoser(有助于注册过程)都使用Session和Token Authentication系统.
如何使用Django-Rest-Framework-JWT覆盖Djoser或Django-Rest-Auth中的令牌认证机制?
authentication django jwt django-rest-framework django-rest-auth
scrollEnabled当滚动到达某个位置时,如何更改React Native ScrollView param的 bool 值?
我确实在 ScrollView 中有一个 ScrollView,由于外部 ScrollView,内部 ScrollView 没有响应。当scrollEnabled参数设置为False外部 ScrollView时,内部 ScrollView 起作用。我的想法是将外部 ScrollView 动态设置为scrollEnabled={false}到达底部时。我该怎么做呢。
谢谢,
react-native react-native-listview react-native-scrollview react-native-android
django ×2
react-native ×2
date ×1
jwt ×1
react-redux ×1
reactjs ×1
recurrence ×1
redux-thunk ×1