I’m working on trying to get the new auth module integrated into an app, using netlify auth, and have run into an issue where I’m not sure if this is a bug, or if I’m doing something wrong. From what I can tell from looking at the code, it appears as if the code is supposed to be returning the user
object when the call to logIn
succeeds. I’m trying to get that user from the logIn
call, so I can set it in application state, but I’m not actually getting anything from the call. My code looks something like this:
const { logIn } = useAuth()
// ...
const login = async () => {
const user = await logIn()
dispatch("loggedIn", user) // <-- `user` here is always null
}
Am I misunderstanding that the call to logIn
should be returning the user? I’ve also tried this as well:
const { currentUser, logIn } = useAuth()
// ...
const login = async () => {
await logIn()
dispatch("loggedIn", currentUser) // <-- `currentUser` here is always null as well
}
I feel like in this case it’s just a timing issue, because I can bind a UI element to currentUser.email
and it gets rendered just fine.
What’s the right way to do what I’m trying here?