How can i solve this error?
TS1109: Expression expected.
I'm new to typescript and I don't understand why is error popping up.
Any suggestions please?
const checkIfUserIsLoggedIn = () : boolean => {
return if (localStorage.getItem("logged-in") === "true" ) {
return <LoggedInMp/>
} else {
return <NotLoggedInMp/>
}
}
You have a few errors in your code. The return
in front of the if
is wrong and the return type of your function may also be off. The first return
is causing the error, because an expression is expected and a if {} else {}
is not an expression.
const checkIfUserIsLoggedIn = () => {
if (localStorage.getItem("logged-in") === "true" ) {
return <LoggedInMp/>;
} else {
return <NotLoggedInMp/>;
}
}