So what I have is this: I want to keep all the 'parse' code inside a manager that I can call from another classes and files. On this example I have a function that will only check if the user is logged in and then return different drawer navigations based on that. The problem is that I keep getting the error 'undefined is not a function (evaluating ...)'. Im kinda new to javascript and couldn't find an answer to this. Here's the code.
Thanks in advance.
ParseManager.js
isUserLogged() {
Parse.User.currentAsync().then(function (user) {
if (user) {
console.log("ParseManager - User logged in.")
return true;
} else {
console.log("ParseManager - User logged off.")
return false;
}
});
App.js
render() {
if (ParseManager.isUserLogged()) {
return (
<SecondaryRoot />
);
} else {
return (
<MainRoot />
);
}
isUserLoggedis not doing what you think it's doing. It's returningundefinedbecauseParse.User...is a promise.