I have this useState statement:
const [userLogged, setUserLogged] = useState();
And this is a fragment of my code in a custom hook:
await axios.post('http://localhost:3000/users/register', form).then( (res)=> {
setUserLogged(res.config.data)
console.log(UserLogged)
window.location.href = "http://localhost:3001/"
});
When my callback is working, i want to set the state of userLogged using setUserLogged with the user object from res, but it doesn't work. If a do a console.log of userLogged state, i get a undefined.
I tried by passing a boolean or string to setUserLogged for testing, but its undefined too.